Пример #1
0
 DefaultWeightedEdge addEdge(final Spot source, final Spot target, final double weight) {
   if (!graph.containsVertex(source)) {
     graph.addVertex(source);
   }
   if (!graph.containsVertex(target)) {
     graph.addVertex(target);
   }
   final DefaultWeightedEdge edge = graph.addEdge(source, target);
   graph.setEdgeWeight(edge, weight);
   return edge;
 }
Пример #2
0
 void addSpot(final Spot spotToAdd) {
   graph.addVertex(spotToAdd);
 }
  @Test
  public void testSubgraph2() {

    ListenableUndirectedGraph<Integer, DefaultEdge> g1 =
        new ListenableUndirectedGraph<Integer, DefaultEdge>(DefaultEdge.class);

    g1.addVertex(0);
    g1.addVertex(1);
    g1.addVertex(2);
    g1.addVertex(3);
    g1.addVertex(4);

    g1.addEdge(0, 1);
    g1.addEdge(0, 4);
    g1.addEdge(1, 2);
    g1.addEdge(1, 4);
    g1.addEdge(2, 3);
    g1.addEdge(2, 4);
    g1.addEdge(3, 4);

    ListenableUndirectedGraph<Integer, DefaultEdge> g2 =
        new ListenableUndirectedGraph<Integer, DefaultEdge>(DefaultEdge.class);

    g2.addVertex(0);
    g2.addVertex(1);
    g2.addVertex(2);
    g2.addVertex(3);
    g2.addVertex(4);
    g2.addVertex(5);

    g2.addEdge(4, 2);
    g2.addEdge(2, 0);
    g2.addEdge(0, 1);
    g2.addEdge(1, 3);
    g2.addEdge(3, 4);
    g2.addEdge(4, 0);
    g2.addEdge(1, 4);

    ListenableUndirectedGraph<Integer, DefaultEdge> g3 =
        new ListenableUndirectedGraph<Integer, DefaultEdge>(DefaultEdge.class);

    g3.addVertex(0);
    g3.addVertex(1);
    g3.addVertex(2);
    g3.addVertex(3);
    g3.addVertex(4);
    g3.addVertex(5);

    g3.addEdge(0, 1);
    g3.addEdge(1, 2);
    g3.addEdge(2, 3);
    g3.addEdge(3, 4);
    g3.addEdge(5, 2);
    g3.addEdge(5, 3);
    g3.addEdge(5, 4);

    ListenableUndirectedGraph<Integer, DefaultEdge> g4 =
        new ListenableUndirectedGraph<Integer, DefaultEdge>(DefaultEdge.class);

    g4.addVertex(0);
    g4.addVertex(1);
    g4.addVertex(2);
    g4.addVertex(3);
    g4.addVertex(4);
    g4.addVertex(5);

    g4.addEdge(0, 1);
    g4.addEdge(1, 2);
    g4.addEdge(2, 3);
    g4.addEdge(4, 5);
    g4.addEdge(4, 2);
    g4.addEdge(5, 2);
    g4.addEdge(5, 3);

    VF2GraphIsomorphismInspector<Integer, DefaultEdge>
        vf2 = new VF2GraphIsomorphismInspector<Integer, DefaultEdge>(g2, g1),
        vf3 = new VF2GraphIsomorphismInspector<Integer, DefaultEdge>(g1, g2),
        vf4 = new VF2GraphIsomorphismInspector<Integer, DefaultEdge>(g3, g4);

    assertEquals(false, vf2.isomorphismExists());
    assertEquals(false, vf3.isomorphismExists());
    assertEquals(false, vf4.isomorphismExists());
  }