public static Graph CreateDrawingGraph(GeometryGraph gg)
 {
     counter = 0;
     localMap = new Dictionary<GeometryNode,Node>();
     dg = new Graph(counter++.ToString()) { GeometryGraph = gg };
     foreach (GeometryNode n in gg.Nodes)
     {
         Node node = new Node(counter++.ToString());
         node.Attr.Shape = Shape.Ellipse;
         node.GeometryNode = n;
         dg.AddNode(node);
         localMap[n]=node;
     }
     Subgraph cluster = new Subgraph(counter++.ToString());
     cluster.GeometryNode = gg.RootCluster;
     dg.RootSubgraph = cluster;
     PopulateClusters(cluster, gg.RootCluster);
 
     foreach (GeometryEdge e in gg.Edges)
     {
         Edge edge = new Edge(localMap[e.Source], localMap[e.Target], ConnectionToGraph.Disconnected);
         edge.Attr.ArrowheadAtSource = e.ArrowheadAtSource ? ArrowStyle.Normal : ArrowStyle.None;
         edge.Attr.ArrowheadAtTarget = e.ArrowheadAtTarget ? ArrowStyle.Normal : ArrowStyle.None;
         edge.GeometryEdge = e;
         dg.AddPrecalculatedEdge(edge);
     }
     //PopulateClusterEdges(dg.RootSubgraph, gg.RootCluster);
     
     return dg;
 }
        static void ProcessLine(Graph graph, string str) {
            if (String.IsNullOrEmpty(str))
                return;
            if (str[0] == '*') return;

            var arrayStr = str.Split(new []{' '},StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (arrayStr.Length == 0)
                return;
            var source = graph.AddNode(arrayStr[0]);
            for (int i = 1; i < arrayStr.Length; i++) {
                var e = new Edge(source, graph.AddNode(arrayStr[i]), ConnectionToGraph.Connected);
                graph.AddPrecalculatedEdge(e);
            }
        }
Example #3
0
        private void ReadEdge()
        {
            CheckToken(Tokens.Edge);
            XmlRead();
            object userData = null;

            if (TokenIs(Tokens.UserData))
            {
                userData = ReadUserData();
            }
            string srcId    = ReadStringElement(Tokens.SourceNodeID);
            string targetId = ReadStringElement(Tokens.TargetNodeID);
            Edge   edge     = null;

            try
            {
                // Only try reading to ensure backward compatibility with older MSAGL file formates
                string edgeTypeName = ReadEdgeType();
                Type   edgeTpye     = GetTypeByName(edgeTypeName);
                Node   srcNode      = graph.FindNode(srcId);
                Node   targetNode   = graph.FindNode(targetId);
                edge = (Edge)Activator.CreateInstance(edgeTpye, new object[] { srcNode, targetNode });
                graph.AddPrecalculatedEdge(edge);
            }
            catch
            {
                edge = graph.AddEdge(srcId, targetId);
            }
            try
            {
                // Only try reading to ensure backward compatibility with older MSAGL file formates
                edge.IsVisible = ReadVisibility();
            }
            catch
            {
                edge.IsVisible = true;
            }
            edge.Attr     = new EdgeAttr();
            edge.UserData = userData;
            ReadEdgeAttr(edge.Attr);
            ReadLabel(edge);
            EdgeList.Add(edge);
            ReadEndElement();
        }