Package org.impalaframework.graph

Examples of org.impalaframework.graph.Vertex


     */
    private List<Vertex> getVertexAndOrderedDependants(String name) {
       
        Assert.notNull(name, "name cannot be null");
       
        final Vertex current = getRequiredVertex(name);
       
        //get all dependents
        final List<Vertex> dependents = getVertexDependants(name);
        List<Vertex> ordered = getOrderedDependants(current, dependents);
        return ordered;
View Full Code Here


     */
    private List<Vertex> getVertexDependencyList(String name) {
       
        Assert.notNull(name, "name cannot be null");
       
        Vertex vertex = getRequiredVertex(name);
       
        //list the vertices in the correct order
        final List<Vertex> vertextList = GraphHelper.list(vertex);
        return vertextList;
    }
View Full Code Here

        Assert.notNull(definitions, "definitions cannot be null");
       
        List<Vertex> vertices = new ArrayList<Vertex>();
        for (ModuleDefinition moduleDefinition : definitions) {
            final Vertex vertex = getRequiredVertex(moduleDefinition.getName());
           
            vertices.add(vertex);
        }
        return vertices;
    }
View Full Code Here

    private Vertex populateVertex(ModuleDefinition moduleDefinition) {
       
        Assert.notNull(moduleDefinition, "moduleDefinition cannot be null");
       
        String name = moduleDefinition.getName();
        final Vertex vertex = new Vertex(moduleDefinition);
        vertexMap.put(name, vertex);
        return vertex;
    }
View Full Code Here

    private void populateDependencies(Vertex vertex, ModuleDefinition moduleDefinition, boolean optional) {
       
        final List<String> dependentModuleNames = moduleDefinition.getDependentModuleNames(optional);
        for (String dependent : dependentModuleNames) {
           
            final Vertex dependentVertex = vertexMap.get(dependent);
           
            if (dependentVertex == null) {
                if (!optional) {
                    throw new InvalidStateException("Unable to find entry for dependency named named '" + dependent
                            + "' for module definition '" + moduleDefinition.getName() + "'");
View Full Code Here

        super( name );
    }

    public void testSortMethods()
    {
        Vertex v = new Vertex( "Root" );
        List<Vertex> deps = v.getDependencies();
        assertNotNull( deps );
        assertEquals( 0, deps.size() );
        assertEquals( null, v.getModuleDefinition() );
        assertEquals( "Root", v.getName() );
        assertEquals( 0, v.getOrder() );

        Vertex w = new Vertex( "Child" );
        v.addDependency( w );
        deps = v.getDependencies();
        assertNotNull( deps );
        assertEquals( 1, deps.size() );

        v.reset();
        w.reset();
       
        try
        {
            v.resolveOrder();
            w.resolveOrder();
        }
        catch ( CyclicDependencyException e )
        {
            fail( "Unexpected cyclic exception: " + e );
        }
       
        assertEquals( 1, v.getOrder() );
        assertEquals( 0, w.getOrder() );
    }
View Full Code Here

    public void testIsDAG()
    {
        try
        {
            Vertex root = new Vertex( "Root" );
            root.addDependency( new Vertex( "Child1" ) );
            root.addDependency( new Vertex( "Child2" ) );

            GraphHelper.verify( root );
        }
        catch ( CyclicDependencyException cde )
        {
            fail( "Incorrectly found a Cycle" );
        }

        try
        {
            Vertex root = new Vertex( "Root" );
            root.addDependency( new Vertex( "Child1" ) );
            root.addDependency( new Vertex( "Child2" ) );

            Vertex child3 = new Vertex( "Child3" );
            child3.addDependency( root );

            root.addDependency( child3 );

            GraphHelper.verify( root );
View Full Code Here

     *  It makes sure that cycles that start a ways into the dependency tree
     *  are handled correctly.
     */
    public void testCycleTest() throws Exception
    {
        Vertex component1 = new Vertex( "Component1" );
        Vertex component2 = new Vertex( "Component2" );
        Vertex component3 = new Vertex( "Component3" );
        Vertex component4 = new Vertex( "Component4" );
        Vertex component5 = new Vertex( "Component5" );
       
        List<Vertex> vertices = new ArrayList<Vertex>( 5 );
        vertices.add( component1 );
        vertices.add( component2 );
        vertices.add( component3 );
        vertices.add( component4 );
        vertices.add( component5 );
       
        component1.addDependency( component2 );
        component2.addDependency( component3 );
           
        component3.addDependency( component4 );
        component4.addDependency( component5 );
        component5.addDependency( component3 ); // Cycle
       
        try
        {
            GraphHelper.topologicalSort( vertices );
            fail( "Did not detect the expected cyclic dependency" );
View Full Code Here

            //Success!
        }
    }
       
    public void testSortDAG() throws Exception {
        Vertex a = new Vertex("a");
        Vertex b = new Vertex("b");
        Vertex c = new Vertex("c");
        Vertex d = new Vertex("d");
        Vertex e = new Vertex("e");
        Vertex f = new Vertex("f");
        Vertex g = new Vertex("g");

        List<Vertex> vertices = new ArrayList<Vertex>();
        vertices.add(a);
        vertices.add(b);
        vertices.add(c);
        vertices.add(d);
        vertices.add(e);
        vertices.add(f);
        vertices.add(g);
       
        b.addDependency(a);
        d.addDependency(b);
        e.addDependency(c);
        e.addDependency(d);
        f.addDependency(b);
        f.addDependency(e);
        g.addDependency(c);
        g.addDependency(d);
        g.addDependency(f);
       
        /*
a
b depends on a
c
View Full Code Here

    }
   
   
    public void testVerifySortDAG() throws Exception
    {
        Vertex component1 = new Vertex( "Component1" );
        Vertex component2 = new Vertex( "Component2" );
        Vertex component3 = new Vertex( "Component3" );
        Vertex component4 = new Vertex( "Component4" );
        Vertex component5 = new Vertex( "Component5" );

        component1.addDependency( component2 );
        component1.addDependency( component3 );

        component3.addDependency( component4 );

        component5.addDependency( component2 );
        component5.addDependency( component4 );

        List<Vertex> vertices = new ArrayList<Vertex>( 5 );
        vertices.add( component1 );
        vertices.add( component2 );
        vertices.add( component3 );
View Full Code Here

TOP

Related Classes of org.impalaframework.graph.Vertex

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.