Graph#edges().
| Modifier and Type | Class and Description |
|---|---|
| private static class | EndpointPairIterator.
If the graph is directed, each ordered [source, target] pair will be visited once if there is an edge connecting them. |
| private static class | EndpointPairIterator.
If the graph is undirected, each unordered [node, otherNode] pair (except self-loops) will be visited twice if there is an edge connecting them. |
| Modifier and Type | Field and Description |
|---|---|
| private final BaseGraph | |
| pack-priv N | |
| private final Iterator | |
| pack-priv Iterator |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final boolean | |
| pack-priv static <N> EndpointPairIterator |
| graph | back to summary |
|---|---|
| private final BaseGraph<N> graph | |
| node | back to summary |
|---|---|
| pack-priv N node
| |
| nodeIterator | back to summary |
|---|---|
| private final Iterator<N> nodeIterator | |
| successorIterator | back to summary |
|---|---|
| pack-priv Iterator<N> successorIterator | |
| EndpointPairIterator | back to summary |
|---|---|
| private EndpointPairIterator(BaseGraph<N> graph) | |
| advance | back to summary |
|---|---|
| pack-priv final boolean advance() Called after | |
| of | back to summary |
|---|---|
| pack-priv static <N> EndpointPairIterator | |
| Modifier and Type | Method and Description |
|---|---|
| protected EndpointPair | computeNext()
Implements abstract com. Note the implementation must call |
| Directed | back to summary |
|---|---|
| private Directed(BaseGraph<N> graph) | |
| computeNext | back to summary |
|---|---|
| protected EndpointPair Implements abstract com. Doc from com. Returns the next element Note the implementation must call The initial invocation of If this method throws an exception, it will propagate outward to the The implementation of this method may not invoke the
| |
EndpointPairs, we keep track of the nodes that we have visited. When processing endpoint
pairs, we skip if the "other node" is in the visited set, as shown below:
Nodes = {N1, N2, N3, N4}
N2 __
/ \ | |
N1----N3 N4__|
Visited Nodes = {}
EndpointPair [N1, N2] - return
EndpointPair [N1, N3] - return
Visited Nodes = {N1}
EndpointPair [N2, N1] - skip
EndpointPair [N2, N3] - return
Visited Nodes = {N1, N2}
EndpointPair [N3, N1] - skip
EndpointPair [N3, N2] - skip
Visited Nodes = {N1, N2, N3}
EndpointPair [N4, N4] - return
Visited Nodes = {N1, N2, N3, N4}
| Modifier and Type | Field and Description |
|---|---|
| private Set |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| protected EndpointPair | computeNext()
Implements abstract com. Note the implementation must call |
| visitedNodes | back to summary |
|---|---|
| private Set<@Nullable N> visitedNodes
| |
| Undirected | back to summary |
|---|---|
| private Undirected(BaseGraph<N> graph) | |
| computeNext | back to summary |
|---|---|
| protected EndpointPair Implements abstract com. Doc from com. Returns the next element Note the implementation must call The initial invocation of If this method throws an exception, it will propagate outward to the The implementation of this method may not invoke the
| |