コード例 #1
1
        public void Run()
        {
            // create an adjacency graph
            AdjacencyGraph g = new AdjacencyGraph(
                new NamedVertexProvider(),
                new NamedEdgeProvider(),
                true
                );

            // create a clustered graph
            ClusteredAdjacencyGraph cg = new ClusteredAdjacencyGraph(g);

            // adding some vertices to the main graph
            NamedVertex a = cg.AddVertex() as NamedVertex; a.Name="a";
            NamedVertex b = cg.AddVertex() as NamedVertex; b.Name="b";
            NamedVertex c = cg.AddVertex() as NamedVertex; c.Name="c";

            NamedEdge ab = cg.AddEdge(a,b) as NamedEdge; ab.Name="ab";
            NamedEdge ac = cg.AddEdge(a,c) as NamedEdge; ac.Name="ac";

            // adding a cluster
            ClusteredAdjacencyGraph cg1 = cg.AddCluster();
            // adding vertices and edges to the cluster
            NamedVertex d = cg1.AddVertex() as NamedVertex; d.Name="d";
            NamedVertex e = cg1.AddVertex() as NamedVertex; e.Name="e";
            NamedVertex f = cg1.AddVertex() as NamedVertex; f.Name="f";
            NamedEdge de = cg1.AddEdge(d,e) as NamedEdge; de.Name="de";
            NamedEdge df = cg1.AddEdge(d,f) as NamedEdge; df.Name="df";

            // adding a second cluster
            ClusteredAdjacencyGraph cg2 = cg.AddCluster();
            // adding vertices
            NamedVertex h = cg2.AddVertex() as NamedVertex; h.Name="h";
            NamedVertex i = cg2.AddVertex() as NamedVertex; i.Name="i";
            NamedEdge hi = cg2.AddEdge(h,i) as NamedEdge; hi.Name="hi";

            // adding a sub-sub-cluster
            ClusteredAdjacencyGraph cg21 = cg2.AddCluster();
            // adding vertices
            NamedVertex k = cg21.AddVertex() as NamedVertex; k.Name="k";
            NamedVertex l = cg21.AddVertex() as NamedVertex; l.Name="l";
            NamedEdge ak = cg.AddEdge(a,k) as NamedEdge; ak.Name="ak";
            NamedEdge kl = cg21.AddEdge(k,l) as NamedEdge; kl.Name="kl";

            // interconnecting
            NamedEdge cd = cg.AddEdge(c,d) as NamedEdge; cd.Name="cd";
            NamedEdge bh = cg.AddEdge(b,h) as NamedEdge; bh.Name="bh";
            NamedEdge ei = cg.AddEdge(e,i) as NamedEdge; ei.Name="ei";

            GraphvizAlgorithm gw = new GraphvizAlgorithm(
                cg,
                "../cluster",
                GraphvizImageType.Svgz
                );
            gw.FormatVertex += new FormatVertexEventHandler(this.FormatVertex);
            gw.FormatEdge += new FormatEdgeEventHandler(this.FormatEdge);
            gw.Write("cluster");

            cg2.Colapsed = true;
            gw.Write("cluster_collapsed");
        }
コード例 #2
0
        /// <summary>
        /// Adds a new cluster.
        /// </summary>
        /// <returns>New cluster</returns>
        public ClusteredAdjacencyGraph AddCluster()
        {
            ClusteredAdjacencyGraph cluster = new ClusteredAdjacencyGraph(this);

            clusters.Add(cluster);
            return(cluster);
        }
コード例 #3
0
 /// <summary>
 /// Constructs a <see cref="ClusteredAdjacencyGraph"/> on top of
 /// the <see cref="AdjacencyGraph"/> object.
 /// </summary>
 /// <param name="wrapped">parent graph</param>
 public ClusteredAdjacencyGraph(AdjacencyGraph wrapped)
 {
     if(wrapped==null)
         throw new ArgumentNullException("parent");
     this.parent = null;
     this.wrapped = wrapped;
     this.clusters = new ArrayList();
     this.colapsed=false;
 }
コード例 #4
0
 public ClusteredAdjacencyGraph(ClusteredAdjacencyGraph parent)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     this.parent = parent;
     this.wrapped = new AdjacencyGraph(this.Parent.VertexProvider, this.Parent.EdgeProvider, this.Parent.AllowParallelEdges);
     this.clusters = new ArrayList();
 }
コード例 #5
0
 /// <summary>
 /// Constructs a <see cref="ClusteredAdjacencyGraph"/> on top of
 /// the <see cref="AdjacencyGraph"/> object.
 /// </summary>
 /// <param name="wrapped">parent graph</param>
 public ClusteredAdjacencyGraph(AdjacencyGraph wrapped)
 {
     if (wrapped == null)
     {
         throw new ArgumentNullException("parent");
     }
     this.parent   = null;
     this.wrapped  = wrapped;
     this.clusters = new ArrayList();
     this.colapsed = false;
 }
コード例 #6
0
 /// <summary>
 /// Construct a cluster inside another cluster
 /// </summary>
 /// <param name="parent"></param>
 public ClusteredAdjacencyGraph(ClusteredAdjacencyGraph parent)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     this.parent  = parent;
     this.wrapped = new AdjacencyGraph(
         Parent.VertexProvider,
         Parent.EdgeProvider,
         Parent.AllowParallelEdges
         );
     this.clusters = new ArrayList();
 }
コード例 #7
0
 /// <summary>
 /// Adds a new cluster.
 /// </summary>
 /// <returns>New cluster</returns>
 public ClusteredAdjacencyGraph AddCluster()
 {
     ClusteredAdjacencyGraph cluster = new ClusteredAdjacencyGraph(this);
     clusters.Add(cluster);
     return cluster;
 }
コード例 #8
0
 public ClusteredAdjacencyGraph AddCluster()
 {
     ClusteredAdjacencyGraph graph = new ClusteredAdjacencyGraph(this);
     this.clusters.Add(graph);
     return graph;
 }