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

LearnLib / automatalib / 6672550055

27 Oct 2023 09:48PM UTC coverage: 89.796% (+0.1%) from 89.69%
6672550055

push

github

mtf90
bump ADDLib version

15832 of 17631 relevant lines covered (89.8%)

1.66 hits per line

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

66.67
/api/src/main/java/net/automatalib/graph/IndefiniteSimpleGraph.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of AutomataLib, http://www.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 com.google.common.collect.Iterators;
22
import net.automatalib.common.util.mapping.MapMapping;
23
import net.automatalib.common.util.mapping.MutableMapping;
24
import org.checkerframework.checker.nullness.qual.Nullable;
25

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

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

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

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

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

85
}
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