コード例 #1
0
ファイル: Graph.cs プロジェクト: iamkrish/Learning
 public Graph( int V, int E)
 {
     DisJointSets = new Subset[V];
     for(int i = 0; i < V; i++)
     {
         DisJointSets[i] = new Subset(i);
     }
     Edges = new Edge[E];
     for (int i = 0; i < E; i++)
     {
         Edges[i] = new Edge();
     }
     GraphVertices = V;
     GraphEdges = E;
 }
コード例 #2
0
ファイル: Graph.cs プロジェクト: iamkrish/Learning
 public int FindPathByCompression(Subset[] subsets,int x)
 {
     if(subsets[x].Parent != x)
     {
         //promote the deep child as the direct child of parent's parent
         subsets[x].Parent = FindPathByCompression(subsets, subsets[x].Parent);
     }
     return subsets[0].Parent;
 }