MCPcopy Create free account
hub / github.com/antlr/codebuff / adjacentNodesString

Method adjacentNodesString

corpus/java/training/guava/graph/Graphs.java:397–411  ·  view source on GitHub ↗

Returns a String of the adjacent node relationships for graph.

(final Graph<N> graph)

Source from the content-addressed store, hash-verified

395 * Returns a String of the adjacent node relationships for {@code graph}.
396 */
397 private static <N> String adjacentNodesString(final Graph<N> graph) {
398 checkNotNull(graph, "graph");
399 List<String> adjacencies = new ArrayList<String>();
400 // This will list each undirected edge twice (once as [n1, n2] and once as [n2, n1]); this is OK
401 for (N node : graph.nodes()) {
402 for (N successor : graph.successors(node)) {
403 adjacencies.add(
404 String.format(
405 graph.isDirected() ? DIRECTED_FORMAT : UNDIRECTED_FORMAT,
406 node, successor));
407 }
408 }
409
410 return String.format("{%s}", Joiner.on(", ").join(adjacencies));
411 }
412
413 /**
414 * Returns a map that is a live view of {@code graph}, with nodes as keys

Callers 1

toStringMethod · 0.95

Calls 8

onMethod · 0.95
nodesMethod · 0.65
successorsMethod · 0.65
addMethod · 0.65
isDirectedMethod · 0.65
checkNotNullMethod · 0.45
formatMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected