private static void printme(RootGraph root) { System.out.println("in RootGraph: " + root.getNodeCount() + " nodes and " + root.getEdgeCount() + " edges"); System.out.println(); }
/** * DOCUMENT ME! * * @param root DOCUMENT ME! * @param nodes DOCUMENT ME! * @param edgeSources DOCUMENT ME! * @param edgeTargets DOCUMENT ME! * @param edgeDirectedness DOCUMENT ME! */ public static final void testAddRemove(RootGraph root, int[] nodes, int[] edgeSources, int[] edgeTargets, boolean[] edgeDirectedness) { for (int i = 0; i < 10; i++) { for (int j = 0; j < nodes.length; j++) root.removeNode(nodes[j]); if ((root.getNodeCount() != 0) || (root.getEdgeCount() != 0)) throw new IllegalStateException("node/edge count not 0"); for (int j = 0; j < nodes.length; j++) nodes[j] = root.createNode(); for (int j = 0; j < edgeSources.length; j++) root.createEdge(nodes[edgeSources[j]], nodes[edgeTargets[i]], edgeDirectedness[j]); if ((root.getNodeCount() != nodes.length) || (root.getEdgeCount() != edgeSources.length)) throw new IllegalStateException("node/edge count not what expected"); } } }
/** * DOCUMENT ME! * * @param args DOCUMENT ME! */ public static void main(String[] args) { final RootGraph root = FingRootGraphFactory.instantiateRootGraph(); final int[] nodeInx = root.createNodes(10000); final int[] edgeInx = new int[100000]; for (int i = 0; i < edgeInx.length; i++) edgeInx[i] = root.createEdge(nodeInx[i % nodeInx.length], nodeInx[(i * 3) % nodeInx.length]); System.out.println("RootGraph node count: " + root.getNodeCount()); System.out.println("RootGraph edge count: " + root.getEdgeCount()); System.out.println(); for (int i = 0; i < 1000; i++) { GraphPerspective persp = root.createGraphPerspective(nodeInx, edgeInx); System.out.println("GraphPerspective node count: " + persp.getNodeCount()); System.out.println("GraphPerspective edge count: " + persp.getEdgeCount()); System.out.println(); } } }
if ((root.getNodeCount() != 5) || (root.getEdgeCount() != 7)) throw new IllegalStateException("incorrect nodes or edges count"); if (root.getEdgeCount(root.getNode(nodeInx[0]), root.getNode(nodeInx[1]), true) != 1) throw new IllegalStateException("wrong number in edge count"); if (root.getEdgeCount(root.getNode(nodeInx[0]), root2Node, true) != -1) throw new IllegalStateException("edge count not -1"); if (root.getEdgeCount(root.getNode(nodeInx[1]), root.getNode(nodeInx[1]), false) != 0) throw new IllegalStateException("edge count not 0"); if (root.getEdgeCount(nodeInx[3], nodeInx[2], true) != 1) throw new IllegalStateException("edge count not 1"); if (root.getEdgeCount(nodeInx[2], nodeInx[3], true) != 0) throw new IllegalStateException("edge count not 0"); if (root.getEdgeCount(nodeInx[1], nodeInx[2], false) != 0) throw new IllegalStateException("edge count not 0"); if (root.getEdgeCount(nodeInx[1], nodeInx[1], true) != 1) throw new IllegalStateException("edge count not 1 for und. self edge"); if (root.getEdgeCount(99, 98, true) != -1) throw new IllegalStateException("edge count not -1"); if ((root.getEdgeCount(Integer.MAX_VALUE, Integer.MIN_VALUE, false) != -1) || (root.getEdgeCount(Integer.MIN_VALUE, Integer.MAX_VALUE, true) != -1))
|| !(root.getEdgeCount(nodeInx[1], nodeInx[3], true) > 0)) throw new IllegalStateException("bad edge count between 2 nodes");