@Test public void testDTSubgraph() { DTGraph<String, String> graph = graph(); System.out.println(Subgraph.dtSubgraph(graph(), Arrays.asList(graph.get(0), graph.get(1)))); }
public static <L, T> DTGraph<L, T> dtSubgraph(DTGraph<L, T> graph, Collection<DTNode<L, T>> nodes) { List<DTNode<L, T>> list = new ArrayList<DTNode<L,T>>(nodes); DTGraph<L, T> out = new MapDTGraph<L, T>(); for(DTNode<L, T> node : list) out.add(node.label()); for(int i : series(nodes.size())) for(int j : series(nodes.size())) for(DTLink<L, T> link : list.get(i).linksOut(list.get(j))) out.get(i).connect(out.get(j), link.tag()); return out; }
Subgraph { public static <L, T> DTGraph<L, T> dtSubgraph(DTGraph<L, T> graph, Collection<DTNode<L, T>> nodes) { List<DTNode<L, T>> list = new ArrayList<DTNode<L,T>>(nodes); DTGraph<L, T> out = new MapDTGraph<L, T>(); for(DTNode<L, T> node : list) out.add(node.label()); for(int i : series(nodes.size())) for(int j : series(nodes.size())) for(DTLink<L, T> link : list.get(i).linksOut(list.get(j))) out.get(i).connect(out.get(j), link.tag()); return out; } }
Subgraph { public static <L, T> DTGraph<L, T> dtSubgraph(DTGraph<L, T> graph, Collection<DTNode<L, T>> nodes) { List<DTNode<L, T>> list = new ArrayList<DTNode<L,T>>(nodes); DTGraph<L, T> out = new MapDTGraph<L, T>(); for(DTNode<L, T> node : list) out.add(node.label()); for(int i : series(nodes.size())) for(int j : series(nodes.size())) for(DTLink<L, T> link : list.get(i).linksOut(list.get(j))) out.get(i).connect(out.get(j), link.tag()); return out; }  }
Subgraph { public static <L, T> DTGraph<L, T> dtSubgraph(DTGraph<L, T> graph, Collection<DTNode<L, T>> nodes) { List<DTNode<L, T>> list = new ArrayList<DTNode<L,T>>(nodes); DTGraph<L, T> out = new MapDTGraph<L, T>(); for(DTNode<L, T> node : list) out.add(node.label()); for(int i : series(nodes.size())) for(int j : series(nodes.size())) for(DTLink<L, T> link : list.get(i).linksOut(list.get(j))) out.get(i).connect(out.get(j), link.tag()); return out; }  static UTGraph<L, T> utSubgraph(UTGraph<L, T> graph, Collection<UTNode<L, T>> nodes); static UTGraph<L, T> utSubgraphIndices(UTGraph<L, T> graph, Collection<Integer> nodes); static DTGraph<L, T> dtSubgraph(DTGraph<L, T> graph, Collection<DTNode<L, T>> nodes); static DTGraph<L, T> dtSubgraphIndices(DTGraph<L, T> graph, Collection<Integer> nodes); static DGraph<L> dSubgraph(DGraph<L> graph, Collection<DNode<L>> nodes); static DGraph<L> dSubgraphIndices(DGraph<L> graph, Collection<Integer> nodes); static Graph<L> subgraph(Graph<L> graph, Collection<Node<L>> nodes); static Graph<L> subgraphIndices(Graph<L> graph, Collection<Integer> nodes); static UGraph<L> uSubgraph(UGraph<L> graph, Collection<UNode<L>> nodes); static UGraph<L> uSubgraphIndices(UGraph<L> graph, Collection<Integer> nodes); }
Subgraph { public static <L, T> DTGraph<L, T> dtSubgraph(DTGraph<L, T> graph, Collection<DTNode<L, T>> nodes) { List<DTNode<L, T>> list = new ArrayList<DTNode<L,T>>(nodes); DTGraph<L, T> out = new MapDTGraph<L, T>(); for(DTNode<L, T> node : list) out.add(node.label()); for(int i : series(nodes.size())) for(int j : series(nodes.size())) for(DTLink<L, T> link : list.get(i).linksOut(list.get(j))) out.get(i).connect(out.get(j), link.tag()); return out; }  static UTGraph<L, T> utSubgraph(UTGraph<L, T> graph, Collection<UTNode<L, T>> nodes); static UTGraph<L, T> utSubgraphIndices(UTGraph<L, T> graph, Collection<Integer> nodes); static DTGraph<L, T> dtSubgraph(DTGraph<L, T> graph, Collection<DTNode<L, T>> nodes); static DTGraph<L, T> dtSubgraphIndices(DTGraph<L, T> graph, Collection<Integer> nodes); static DGraph<L> dSubgraph(DGraph<L> graph, Collection<DNode<L>> nodes); static DGraph<L> dSubgraphIndices(DGraph<L> graph, Collection<Integer> nodes); static Graph<L> subgraph(Graph<L> graph, Collection<Node<L>> nodes); static Graph<L> subgraphIndices(Graph<L> graph, Collection<Integer> nodes); static UGraph<L> uSubgraph(UGraph<L> graph, Collection<UNode<L>> nodes); static UGraph<L> uSubgraphIndices(UGraph<L> graph, Collection<Integer> nodes);  }