Example #1
0
 private void AddEdge(int i, int j, int x, int y, MyMapNode[,] temp_map)
 {
     if (temp_map[x, y].cost > 0)
     {
         MyGraphEdge edge = new MyGraphEdge(temp_map[i, j].index, temp_map[x, y].index, temp_map[i, j].cost);
         m_cGraph.AddEdge(edge);
     }
 }
Example #2
0
        public void TestMethod1()
        {
            MyListGraph graph = new MyListGraph();

            graph.AddNode(new MyGraphNode(0));
            graph.AddNode(new MyGraphNode(1));
            graph.AddNode(new MyGraphNode(2));
            graph.AddNode(new MyGraphNode(3));
            graph.AddNode(new MyGraphNode(4));

            graph.AddEdge(new MyGraphEdge(0, 2));
            graph.AddEdge(new MyGraphEdge(2, 1));

            graph.AddEdge(new MyGraphEdge(2, 3));
            graph.AddEdge(new MyGraphEdge(4, 3));

            Assert.AreEqual(1, graph.SoMienDoThiLienThong());
        }