コード例 #1
0
ファイル: DotGenerator.cs プロジェクト: Qorpent/qorpent.sys
		/// <summary>
		/// Формирует программу на языке DOT
		/// </summary>
		/// <param name="subGraph"></param>
		/// <returns></returns>
		public string Generate(SubGraph subGraph)
		{
		    Graph g;
		    if (subGraph is Graph)
		    {
		        g =(Graph) subGraph;
		    }
		    else
		    {
		        g = new Graph();
		        g.AddSubGraph(subGraph);
		    }
		    return GraphRender.Create(g).GenerateGraphScript();
		}
コード例 #2
0
        /// <summary>
        /// Формирует программу на языке DOT
        /// </summary>
        /// <param name="subGraph"></param>
        /// <returns></returns>
        public string Generate(SubGraph subGraph)
        {
            Graph g;

            if (subGraph is Graph)
            {
                g = (Graph)subGraph;
            }
            else
            {
                g = new Graph();
                g.AddSubGraph(subGraph);
            }
            return(GraphRender.Create(g).GenerateGraphScript());
        }
コード例 #3
0
 private void WriteGraphBody(SubGraph g)
 {
     WriteGraphAttributes(g);
     WriteDefaultNode(g);
     WriteDefaultEdge(g);
     foreach (var n in g.Nodes)
     {
         WriteNode(n);
     }
     foreach (var sg in g.SubGraphs)
     {
         WriteSubgraph(sg);
     }
     foreach (var edge in g.Edges)
     {
         WriteEdge(edge);
     }
 }
コード例 #4
0
 /// <summary>
 /// Перемещает узлы по подграфам
 /// </summary>
 public void MoveNodesToSubgraphs()
 {
     foreach (var n in Nodes.ToArray())
     {
         if (!string.IsNullOrWhiteSpace(n.SubgraphCode))
         {
             var sg = ResolveSubgraph(n.SubgraphCode);
             if (null == sg)
             {
                 sg = new SubGraph {
                     Code = n.SubgraphCode, Parent = this
                 };
                 SubGraphs.Add(sg);
             }
             sg.Nodes.Add(n);
             n.Parent = sg;
             Nodes.Remove(n);
         }
     }
 }
コード例 #5
0
ファイル: SubGraph.cs プロジェクト: Qorpent/qorpent.sys
        /// <summary>
        /// 
        /// </summary>
        /// <param name="subgraph"></param>
        public SubGraph AddSubGraph(SubGraph subgraph)
        {
            var existed = ResolveSubgraph(subgraph.Code);

            if (null != existed) {
                existed.Merge(subgraph);
            }
            else {
                existed = new SubGraph {Code = subgraph.Code};
                existed.Merge(subgraph);
            }
            foreach (var n in subgraph.Nodes) {
                AddNode(n);
            }
            foreach (var e in subgraph.Edges) {
                AddEdge(e);
            }
            foreach (var s in subgraph.SubGraphs) {
                existed.AddSubGraph(s);
            }
            return existed;
        }
コード例 #6
0
 private void CheckoutNamespace(Graph graph, string ns) {
     if (string.IsNullOrWhiteSpace(ns)) return;
     var parts = ns.Split('.');
     var fullns = "";
     SubGraph parent = graph;
     foreach (var p in parts) {
         fullns += p + "__";
         SubGraph ex = null;
         if (null == (ex=parent.ResolveSubgraph(fullns))) {
             parent.SubGraphs.Add((ex=new SubGraph{Code = fullns,Label = p}));
         }
         parent = ex;
     }
 }
コード例 #7
0
ファイル: Graph.cs プロジェクト: Qorpent/qorpent.sys
 /// <summary>
 /// Перемещает узлы по подграфам
 /// </summary>
 public void MoveNodesToSubgraphs()
 {
     foreach (var n in Nodes.ToArray())
     {
         if (!string.IsNullOrWhiteSpace(n.SubgraphCode))
         {
             var sg = ResolveSubgraph(n.SubgraphCode);
             if (null == sg) {
                 sg = new SubGraph {Code = n.SubgraphCode, Parent = this};
                 SubGraphs.Add(sg);
             }
             sg.Nodes.Add(n);
             n.Parent = sg;
             Nodes.Remove(n);
         }
     }
 }
コード例 #8
0
 private void WriteSubgraph(SubGraph sg)
 {
     OpenSubgraph(sg);
     WriteGraphBody(sg);
     CloseSubgraph();
 }