Package org.mantikhor.llapi

Examples of org.mantikhor.llapi.Graph


     */
    public void testGetSubgraph()
    {
        assertNotNull(this.treeI);
        ResourceNode nodeA = (ResourceNode)getNode(TreeImplTest.NODES.A);
        Graph graph1 = this.treeI.getSubgraph(nodeA);
        assertNotNull(graph1);
        TreeImpl tree1 = TreeImpl.valueByResourceNode((ResourceNode)graph1.getNamenode());
        GraphInformation graphInformation1 = tree1.getGraphInformation();
        assertTrue(graphInformation1.getBaseProperties().size() == 3);
        assertTrue(graphInformation1.getBaseValNodes().size() == 4);
        assertTrue(graphInformation1.getPropertyDefinitions().size() == 3);
        assertTrue(graphInformation1.getPropertiesThatAreKhoronItems().size() == 3);
        assertTrue(graphInformation1.getTerminatingBaseProperties().size() == 3);
        assertTrue(graphInformation1.getValNodesThatAreBursts().size() == 4);
       
        ResourceNode nodeF = (ResourceNode)getNode(TreeImplTest.NODES.F);
        Graph graph2 = this.treeI.getSubgraph(nodeF);
        assertNotNull(graph2);
       
        TreeImpl treeIsubgraphFromF = TreeImpl.valueByResourceNode((ResourceNode)graph2.getNamenode());
        GraphInformation graphInformation2 = treeIsubgraphFromF.getGraphInformation();
        assertTrue(graphInformation2.getBaseProperties().size() == 0);
        assertTrue(graphInformation2.getBaseValNodes().size() == 1);
        assertTrue(graphInformation2.getPropertyDefinitions().size() == 0);
        assertTrue(graphInformation2.getPropertiesThatAreKhoronItems().size() == 0);
View Full Code Here


        //                           |_|___________| | | |
        //                             |_____________| | |
        //                             |_______________| |
        //                             |_________________|
       
        Graph treeIII =
            TreeImpl.valueByResourceNode(resNode);
        System.out.println("BEGIN TREEIII");
        String s = treeIII.toString();
        System.out.println(s);
        System.out.println("END TREEIII");
        assertTrue(TreeImpl.isTree(treeIII));
       
        assertFalse(treeIII.isContentContainedBy(burst));
        assertFalse(burst.isContentContainedBy(treeIII));
        assertFalse(treeIII.getNamenode().isContentContainedBy(burst));
        assertTrue(burst.isContentContainedBy(treeIII.getNamenode()));

        Map map = GraphInformation.recursivelyAnalyzeGraph(resNode);
        List<BaseProperty> pRops = GraphInformation.getBaseProperties(map);
       
        Burst burst2 = new BurstImpl(pRops, false);
        assertTrue(burst2.getProperties().containsAll(burst.getProperties()));
        assertTrue(burst.getProperties().containsAll(burst2.getProperties()));
       
        // this makes sense ... tree1 only has A, B, C but tree2 has A, B, ... L.
        assertFalse(this.treeI.hasSameContents(treeIII));
        assertTrue(this.treeI.isContentContainedBy(treeIII));
       
        // Same paths for tree2 as for tree1
        Set<Path> pathsTreeIII = treeIII.getPathset();
        assertTrue(pathsTreeIII.size()==this.numberOfTerminatingNodes);
       
        Set<Path> pathsTreeI = treeI.getPathset();
        assertTrue(pathsTreeI.size()==this.numberOfTerminatingNodes);
       
        assertFalse(pathsTreeI.containsAll(pathsTreeIII));

        Path[] treeIPaths = new Path[pathsTreeI.size()];
        pathsTreeI.toArray(treeIPaths);
       
        Path[] treeIIIPaths = new Path[pathsTreeIII.size()];
        pathsTreeIII.toArray(treeIIIPaths);
       
        List<BaseProperty> propertiesInTreeI = new ArrayList<BaseProperty>();
        for (Path path : treeIPaths)
        {
            propertiesInTreeI.addAll(path.getProperties());
        }
       
        List<BaseProperty> propertiesInTreeIII = new ArrayList<BaseProperty>();
        for (Path path : treeIIIPaths)
        {
            propertiesInTreeIII.addAll(path.getProperties());
        }
       
        assertTrue(propertiesInTreeI.containsAll(propertiesInTreeIII));
        assertTrue(propertiesInTreeIII.containsAll(propertiesInTreeI));

        assertTrue(propertiesInTreeI.size() == this.numberOfTerminatingNodes*2);
        assertTrue(propertiesInTreeIII.size() == this.numberOfTerminatingNodes*2);

        Set<BaseProperty> propSetTI = new HashSet<BaseProperty>(propertiesInTreeI);
        assertTrue(propSetTI.size() == this.numberOfProperties);

        Set<BaseProperty> propSetTIII = new HashSet<BaseProperty>(propertiesInTreeIII);
        assertTrue(propSetTIII.size() == this.numberOfProperties);
       
        Set<BaseProperty> AtoL = new HashSet<BaseProperty>(properties);
        assertTrue(AtoL.containsAll(propSetTI));
        assertTrue(propSetTI.containsAll(AtoL));

        assertTrue(AtoL.containsAll(propSetTIII));
        assertTrue(propSetTIII.containsAll(AtoL));

        // Can we verify that the paths in treeIII are:
       
        // [nTIII, A, D], [nTIII, A, E], [nTIII, A, F],
        // [nTIII, B, G], [nTIII, B, H], [nTIII, B, I],
        // [nTIII, C, J], [nTIII, C, K], [nTIII, C, L]   

        List<Path> pathsInTreeIII = new ArrayList<Path>(9);

        for ( int ndx1 = TreeImplTest.PROPERTIES.A.ordinal();
              ndx1 < TreeImplTest.PROPERTIES.C.ordinal() + 1;
              ndx1++)
        {
            // 0 -> 3,4,5, 1 -> 6,7,8, 2 -> 9,10,11
            int start = (ndx1 + 1) * 3;
            for (int ndx2 = 0; ndx2 < 3; ndx2++)
            {
                List<BaseProperty> theProps = new ArrayList<BaseProperty>(2);
                theProps.add(getProperty(TreeImplTest.PROPERTIES.values()[ndx1]));
                theProps.add(getProperty(TreeImplTest.PROPERTIES.values()[start + ndx2]));
                Path aPathInTreeIII = PathImpl.newInstance(treeIII.getNamenode(), theProps);
                pathsInTreeIII.add(aPathInTreeIII);
                assertTrue(pathsTreeIII.contains(aPathInTreeIII));               
            }
        }
       
View Full Code Here

        if (!this.graphInformation.getValNodesThatAreResourceNodes().values().contains(newStartNode))
        {
            throw new IllegalArgumentException("cannot find newStartNode in this TreeImpl");
        }

        Graph g = this.getSubgraph(newStartNode);
        return g.getPathset();
    }
View Full Code Here

        }

        // see if all the content in this instance is in other
        // that would be namenode and properties

        Graph otherAsGraph = (Graph)other;
        Namenode othersNameNode = otherAsGraph.getNamenode();

        if (!this.namenode.isContentContainedBy(othersNameNode))
        {
            return false;
        }

        List<BaseProperty> othersProperties = otherAsGraph.getAllProperties();
        List<BaseProperty> thisProperties = this.graphInformation.getBaseProperties();

        if (!(othersProperties.containsAll(thisProperties)))
        {
            return false;
View Full Code Here

TOP

Related Classes of org.mantikhor.llapi.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.