GraphMLReader2 implements GraphReader<G, N, E> { public GraphMLDocument getGraphMLDocument() { return document; } GraphMLReader2(
      Reader fileReader,
      Function<GraphMetadata, G> graphTransformer,
      Function<NodeMetadata, N> nodeTransformer,
      Function<EdgeMetadata, E> edgeTransformer);  GraphMLReader2(
      InputStream inputStream,
      Function<GraphMetadata, G> graphTransformer,
      Function<NodeMetadata, N> nodeTransformer,
      Function<EdgeMetadata, E> edgeTransformer); Function<GraphMetadata, G> getGraphTransformer(); Function<NodeMetadata, N> getNodeTransformer(); Function<EdgeMetadata, E> getEdgeTransformer(); void init(); void close(); GraphMLDocument getGraphMLDocument(); @SuppressWarnings("unchecked") G readGraph();  }
@Test public void testAttributesFile() throws Exception { Network<DummyNode, DummyEdge> graph = readGraphFromFile( "attributes.graphml", new DummyGraphObjectBase.UndirectedNetworkFactory(), new DummyNode.Factory(), new DummyEdge.EdgeFactory()); Assert.assertEquals(6, graph.nodes().size()); Assert.assertEquals(7, graph.edges().size()); Assert.assertEquals(1, reader.getGraphMLDocument().getGraphMetadata().size()); int id = 0; List<NodeMetadata> nodes = new ArrayList<NodeMetadata>( reader.getGraphMLDocument().getGraphMetadata().get(0).getNodeMap().values()); Collections.sort( nodes, new Comparator<NodeMetadata>() { public int compare(NodeMetadata o1, NodeMetadata o2) { return o1.getId().compareTo(o2.getId()); } }); Assert.assertEquals(6, nodes.size()); for (NodeMetadata md : nodes) { Assert.assertEquals('n', md.getId().charAt(0)); Assert.assertEquals(id++, Integer.parseInt(md.getId().substring(1))); } id = 0; List<EdgeMetadata> edges = new ArrayList<EdgeMetadata>( reader.getGraphMLDocument().getGraphMetadata().get(0).getEdgeMap().values()); Collections.sort( edges, new Comparator<EdgeMetadata>() { public int compare(EdgeMetadata o1, EdgeMetadata o2) { return o1.getId().compareTo(o2.getId()); } }); Assert.assertEquals(7, edges.size()); for (EdgeMetadata md : edges) { Assert.assertEquals('e', md.getId().charAt(0)); Assert.assertEquals(id++, Integer.parseInt(md.getId().substring(1))); } Assert.assertEquals("green", nodes.get(0).getProperties().get("d0")); Assert.assertEquals("yellow", nodes.get(1).getProperties().get("d0")); Assert.assertEquals("blue", nodes.get(2).getProperties().get("d0")); Assert.assertEquals("red", nodes.get(3).getProperties().get("d0")); Assert.assertEquals("yellow", nodes.get(4).getProperties().get("d0")); Assert.assertEquals("turquoise", nodes.get(5).getProperties().get("d0")); Assert.assertEquals("1.0", edges.get(0).getProperties().get("d1")); Assert.assertEquals("1.0", edges.get(1).getProperties().get("d1")); Assert.assertEquals("2.0", edges.get(2).getProperties().get("d1")); Assert.assertEquals(null, edges.get(3).getProperties().get("d1")); Assert.assertEquals(null, edges.get(4).getProperties().get("d1")); Assert.assertEquals(null, edges.get(5).getProperties().get("d1")); Assert.assertEquals("1.1", edges.get(6).getProperties().get("d1")); }