示例#1
0
  public void testUndirectedAdjacencyList() {
    UndirectedGraph<Integer, DefaultEdge> g = new Pseudograph<>(DefaultEdge.class);
    g.addVertex(1);
    g.addVertex(2);
    g.addVertex(3);
    g.addVertex(4);
    g.addVertex(5);
    g.addEdge(1, 2);
    g.addEdge(1, 3);
    g.addEdge(3, 1);
    g.addEdge(3, 4);
    g.addEdge(4, 5);
    g.addEdge(5, 1);
    g.addEdge(5, 2);
    g.addEdge(5, 3);
    g.addEdge(5, 4);
    g.addEdge(5, 5);
    g.addEdge(5, 5);

    CSVExporter<Integer, DefaultEdge> exporter =
        new CSVExporter<>(nameProvider, CSVFormat.ADJACENCY_LIST, ';');
    StringWriter w = new StringWriter();
    exporter.exportGraph(g, w);
    assertEquals(UNDIRECTED_ADJACENCY_LIST, w.toString());
  }
示例#2
0
  public void testUndirected() {
    UndirectedGraph<String, DefaultEdge> g =
        new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
    g.addVertex(V1);
    g.addVertex(V2);
    g.addEdge(V1, V2);
    g.addVertex(V3);
    g.addEdge(V3, V1);

    StringWriter w = new StringWriter();
    exporter.export(w, g);
    assertEquals(UNDIRECTED, w.toString());
  }
示例#3
0
  public void testAdjacencyUndirected() {
    UndirectedGraph<String, DefaultEdge> g =
        new Pseudograph<String, DefaultEdge>(DefaultEdge.class);
    g.addVertex(V1);
    g.addVertex(V2);
    g.addEdge(V1, V2);
    g.addVertex(V3);
    g.addEdge(V3, V1);
    g.addEdge(V1, V1);

    StringWriter w = new StringWriter();
    exporter.exportAdjacencyMatrix(w, g);
    assertEquals(UNDIRECTED_ADJACENCY, w.toString());
  }
示例#4
0
  public void testLaplacian() {
    UndirectedGraph<String, DefaultEdge> g =
        new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
    g.addVertex(V1);
    g.addVertex(V2);
    g.addEdge(V1, V2);
    g.addVertex(V3);
    g.addEdge(V3, V1);

    StringWriter w = new StringWriter();
    exporter.exportLaplacianMatrix(w, g);
    assertEquals(LAPLACIAN, w.toString());

    w = new StringWriter();
    exporter.exportNormalizedLaplacianMatrix(w, g);
    assertEquals(NORMALIZED_LAPLACIAN, w.toString());
  }