예제 #1
0
파일: Graph.cs 프로젝트: sokolowskip/WMH
 public static Graph CreateBipartiteGraph(int n, int m)
 {
     var graph = new Graph();
     graph.AddVerticiesRange(n + m);
     for (int i = 0; i < n; i++)
     {
         for (int j = n; j < n+m; j++)
         {
             graph.AddUndirectedEdge(i, j);
         }
     }
     return graph;
 }
예제 #2
0
파일: Graph.cs 프로젝트: sokolowskip/WMH
        public static Graph CreateCompleteGraph(int size)
        {
            var graph = new Graph();
            graph.AddVerticiesRange(size);

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    graph.AddUndirectedEdge(i, j);
                }
            }
            return graph;
        }
예제 #3
0
파일: Graph.cs 프로젝트: sokolowskip/WMH
 public Graph Shrink(int n, int m)
 {
     var h = new Graph();
     foreach (var v in AllVerticies.Where(x => x.Id != m))
     {
         h.AddVertex(v.Id);
     }
     foreach (var vertex in AllVerticies.Where(x => x.Id != m))
     {
         foreach (var neighbour in vertex.AllNeighbours.Where(x => x.Id != m))
         {
             h.AddDirectedEdge(vertex.Id, neighbour.Id);
         }
     }
     var mVertex = verticies[m];
     foreach (var neighbourOfM in mVertex.AllNeighbours.Where(x => x.Id != n))
     {
         h.AddUndirectedEdge(n, neighbourOfM.Id);
     }
     return h;
 }