• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / automatalib / 13138848026

04 Feb 2025 02:53PM UTC coverage: 92.108% (+2.2%) from 89.877%
13138848026

push

github

mtf90
[maven-release-plugin] prepare release automatalib-0.12.0

16609 of 18032 relevant lines covered (92.11%)

1.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/api/src/main/java/net/automatalib/graph/IndefiniteSimpleGraph.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of AutomataLib <https://automatalib.net>.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.automatalib.graph;
17

18
import java.util.Iterator;
19
import java.util.Objects;
20

21
import net.automatalib.common.util.collection.IteratorUtil;
22
import net.automatalib.common.util.mapping.MapMapping;
23
import net.automatalib.common.util.mapping.MutableMapping;
24

25
/**
26
 * A simplified interface for indefinite graphs, exposing only adjacency information, but no further information about
27
 * edge objects.
28
 *
29
 * @param <N>
30
 *         node type
31
 */
32
public interface IndefiniteSimpleGraph<N> extends Iterable<N> {
33

34
    /**
35
     * Retrieves, for a given node, all adjacent nodes.
36
     *
37
     * @param node
38
     *         the node
39
     *
40
     * @return an iterator over the adjacent nodes
41
     */
42
    Iterator<N> getAdjacentNodesIterator(N node);
43

44
    /**
45
     * Checks, for two given nodes, whether they are connected.
46
     *
47
     * @param source
48
     *         the source node
49
     * @param target
50
     *         the target node
51
     *
52
     * @return {@code true} if the nodes are connect, {@code false} otherwise
53
     */
54
    default boolean isConnected(N source, N target) {
55
        return IteratorUtil.any(getAdjacentNodesIterator(source), n -> Objects.equals(n, target));
1✔
56
    }
57

58
    /**
59
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this graph's nodes. The returned
60
     * mapping is however only guaranteed to work correctly if the transition system is not modified.
61
     *
62
     * @param <V>
63
     *         the value type of the mapping
64
     *
65
     * @return the mutable mapping
66
     */
67
    default <V> MutableMapping<N, V> createStaticNodeMapping() {
68
        return new MapMapping<>();
×
69
    }
70

71
    /**
72
     * Creates a {@link MutableMapping} allowing to associate arbitrary data with this graph's nodes. The returned
73
     * mapping maintains the association even when the transition system is modified.
74
     *
75
     * @param <V>
76
     *         the value type of the mapping
77
     *
78
     * @return the mutable mapping
79
     */
80
    default <V> MutableMapping<N, V> createDynamicNodeMapping() {
81
        return new MapMapping<>();
×
82
    }
83

84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc