public void AddEdge()
        {
            SimpleGraph graph = new SimpleGraph();

            Vertex A = graph.CreateVertex( "A" );
            Vertex B = graph.CreateVertex( "B" );

            Edge edge = graph.CreateEdge( A, B );

            AssertNotNull( edge );

            AssertEquals( A, edge.Source );
            AssertEquals( B, edge.Target );
            AssertEquals( 1, A.Successors.Length );
            AssertEquals( 0, B.Successors.Length );
        }
        public void BiggerSituation()
        {
            SimpleGraph graph = new SimpleGraph();

            Vertex A = graph.CreateVertex( "A" );
            Vertex B = graph.CreateVertex( "B" );
            Vertex C = graph.CreateVertex( "C" );
            Vertex D = graph.CreateVertex( "D" );
            Vertex E = graph.CreateVertex( "E" );
            Vertex F = graph.CreateVertex( "F" );
            Vertex G = graph.CreateVertex( "G" );

            graph.CreateEdge( B, C );
            graph.CreateEdge( A, C );
            graph.CreateEdge( C, E );
            graph.CreateEdge( B, E );
            graph.CreateEdge( A, E );
            graph.CreateEdge( E, F );
            graph.CreateEdge( F, G );

            Vertex[] vertices = TopologicalSort.Perform( graph );
            Vertex[] expected = new Vertex[] { A, B, D, C, E, F, G };

            AssertNotNull( vertices );
            AssertEquals( expected, vertices );
        }
        public void AddVertex()
        {
            SimpleGraph graph = new SimpleGraph();

            Vertex A = graph.CreateVertex( "A" );

            AssertNotNull( A );
            AssertEquals( "A", A.Content );
            AssertEquals( 1, graph.Vertices.Length );
        }
        public void SimpleUse()
        {
            SimpleGraph graph = new SimpleGraph();

            Vertex A = graph.CreateVertex( "A" );
            Vertex B = graph.CreateVertex( "B" );
            Vertex C = graph.CreateVertex( "C" );
            Vertex D = graph.CreateVertex( "D" );
            Vertex E = graph.CreateVertex( "E" );

            graph.CreateEdge( A, B );
            graph.CreateEdge( A, C );
            graph.CreateEdge( C, D );

            Vertex[] vertices = TopologicalSort.Perform( graph );
            Vertex[] expected = new Vertex[] { A, E, B, C, D };

            AssertNotNull( vertices );
            AssertEquals( expected, vertices );
        }
Ejemplo n.º 5
0
        protected virtual SimpleGraph BuildHandlerGraph()
        {
            SimpleGraph graph = new SimpleGraph();

            foreach( IHandler handler in m_key2Handler.Values )
            {
                graph.CreateVertex( handler.ComponentModel.Service );
            }

            foreach( IHandler handler in m_key2Handler.Values )
            {
                Type service = handler.ComponentModel.Service;
                IDependencyModel[] dependencies = handler.ComponentModel.Dependencies;

                foreach(IDependencyModel dependency in dependencies)
                {
                    graph.CreateEdge( graph[service], graph[dependency.Service] );
                }
            }

            return graph;
        }