コード例 #1
0
    //测试稠密有权图
    //测试稀疏有权图
    public void testWeightDSGraph()
    {
        string name = "";
        string url  = "";

        //测试稠密有权图~
        print("测试稠密有权图");
        WeightDenseGraph <float> wdGraph = null;

        name = "testWeightG1.txt";
        url  = FileHelper.FileNameHelper(name);
        ReadWeightGraph.ReadGraphFromFile(url, out wdGraph, false);       // out不可缺少
        wdGraph.print();

        //测试稀疏有权图
        print("测试稀疏有权图");
        WeightSpareGraph <float> wsGraph = null;

        ReadWeightGraph.ReadGraphFromFile(url, out wsGraph, false);
        wsGraph.print();
    }
コード例 #2
0
    public static void ReadGraphFromFile(string fileName, out WeightDenseGraph <float> graph, bool isDirected)
    {
        int   V, E;
        float W;

        string[] strs = File.ReadAllLines(fileName);
        Debug.Assert(strs.Length >= 2);
        string veline = strs [0];

        readGraphFileVELine(veline, out V, out E);
        Debug.Log("V , E " + V + "," + E);
        graph = new WeightDenseGraph <float>(V, isDirected);
        for (int i = 0; i != E; i++)
        {
            string line = strs [i + 1];
            int    p, q;
            float  w;
            readGraphFileVEWLine(line, out p, out q, out w);
//			Debug.Log ("V , E , W" + p +"," + q+" , "+ w);
            graph.AddEdge(p, q, w);
        }
    }
コード例 #3
0
 int v;        //从0开始~
 public adjIterator(WeightDenseGraph <Weight> graph, int v)
 {
     this.G     = graph;
     this.v     = v;
     this.index = 0;
 }