MCPcopy
hub / github.com/google/guava / edges

Method edges

guava/src/com/google/common/graph/AbstractNetwork.java:65–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63 }
64
65 @Override
66 public Set<EndpointPair<N>> edges() {
67 if (allowsParallelEdges()) {
68 return super.edges(); // Defer to AbstractGraph implementation.
69 }
70
71 // Optimized implementation assumes no parallel edges (1:1 edge to EndpointPair mapping).
72 return new AbstractSet<EndpointPair<N>>() {
73 @Override
74 public Iterator<EndpointPair<N>> iterator() {
75 return Iterators.transform(
76 AbstractNetwork.this.edges().iterator(), edge -> incidentNodes(edge));
77 }
78
79 @Override
80 public int size() {
81 return AbstractNetwork.this.edges().size();
82 }
83
84 // Mostly safe: We check contains(u) before calling successors(u), so we perform unsafe
85 // operations only in weird cases like checking for an EndpointPair<ArrayList> in a
86 // Network<LinkedList>.
87 @SuppressWarnings("unchecked")
88 @Override
89 public boolean contains(@Nullable Object obj) {
90 if (!(obj instanceof EndpointPair)) {
91 return false;
92 }
93 EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
94 return isOrderingCompatible(endpointPair)
95 && nodes().contains(endpointPair.nodeU())
96 && successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
97 }
98 };
99 }
100
101 @Override
102 public ElementOrder<N> nodeOrder() {

Callers 1

edgeInvalidatableSetMethod · 0.95

Calls 2

allowsParallelEdgesMethod · 0.65
edgesMethod · 0.65

Tested by

no test coverage detected