Пример #1
0
        protected Edge AddEdge(GraphWriter g, Node sourceNode, Node targetNode, string name)
        {
            string source = sourceNode.ID;
            string target = targetNode.ID;
            Edge   edge   = g.AddEdge(source, target);

            edge.Label     = name;
            edge.FontSize  = 8;
            edge.FontColor = Color.LightGray;
            return(edge);
        }
Пример #2
0
 protected void AddDependencyEdges(GraphWriter g, Node nd, DependencyInformation di, Stage stage, Stage parentStage)
 {
     foreach (IStatement source in di.GetDependenciesOfType(DependencyType.Dependency | DependencyType.Declaration))
     {
         Node nd2 = GetNodeForStatement(source, stage);
         if (nd2 == null)
         {
             continue;
         }
         bool backwards = ((int)nd.UserData) < ((int)nd2.UserData);
         //Console.WriteLine("stage=" + stage + " " + nd.UserData + " " + nd2.UserData);
         Edge e;
         if (backwards)
         {
             e         = g.AddEdge(nd.ID, nd2.ID);
             e.Color   = Color.Red;
             e.Reverse = true;
         }
         else
         {
             e = g.AddEdge(nd2.ID, nd.ID);
             if (parentStage != stage)
             {
                 e.Color = Color.LightGray;
             }
         }
         if (di.HasDependency(DependencyType.Trigger, source))
         {
             e.Width = 2;
         }
         if (di.HasDependency(DependencyType.Fresh, source))
         {
             e.Style = EdgeStyle.Dashed;
         }
         if (di.HasDependency(DependencyType.Cancels, source))
         {
             e.Color = Color.LightGray;
         }
     }
     //e.Label = StatementLabel(ist);            e.Label.FontSize = 8;
 }
Пример #3
0
        private void Add(GraphWriter g, ModelBuilder mb)
        {
            Count = 0;
            if (mb == null)
            {
                return;
            }
            foreach (IModelExpression me in mb.ModelExpressions)
            {
                if (me is MethodInvoke)
                {
                    AddFactorEdges(g, (MethodInvoke)me);
                }
            }
            // connect nodes that represent the same variable with undirected edges
            Dictionary <Variable, List <Node> > nodesOfVariable = new Dictionary <Variable, List <Node> >();

            foreach (KeyValuePair <IModelExpression, Node> entry in nodeOfExpr)
            {
                if (!(entry.Key is Variable))
                {
                    continue;
                }
                Variable v = (Variable)entry.Key;
                v = GetBaseVariable(v);
                List <Node> nodes;
                if (!nodesOfVariable.TryGetValue(v, out nodes))
                {
                    nodes = new List <Node>();
                    nodesOfVariable[v] = nodes;
                }
                nodes.Add(entry.Value);
            }
            foreach (List <Node> nodes in nodesOfVariable.Values)
            {
                for (int i = 0; i < nodes.Count; i++)
                {
                    for (int j = 0; j < nodes.Count; j++)
                    {
                        if (i != j && childNodes.Contains(nodes[i]))
                        {
                            // Graph layout tools use the edge direction as a layout hint, so only use child nodes as sources
                            Edge edge = g.AddEdge(nodes[i].ID, nodes[j].ID);
                            edge.ArrowheadAtTarget = ArrowheadStyle.None;
                        }
                    }
                }
            }
        }
Пример #4
0
        protected Node GetNode(GraphWriter g, ConditionContext context)
        {
            Node node;

            if (!nodeOfContext.TryGetValue(context, out node))
            {
                node = g.AddNode("node" + (Count++));
                nodeOfContext[context] = node;
                node.Label             = context.GetLabel();
                node.UserData          = this.GroupInstance;
                ConditionContext parent = context.GetParentContext();
                if (parent != null)
                {
                    var parentNode = GetNode(g, parent);
                    AddGroupEdge(g, parentNode, node);
                }
                var  variable      = context.GetConditionVariable();
                Node conditionNode = GetNode(g, variable);
                g.AddEdge(conditionNode.ID, node.ID);
            }
            return(node);
        }
Пример #5
0
        protected void AddGroupEdge(GraphWriter g, Node parent, Node child)
        {
            Edge edge = g.AddEdge(parent.ID, child.ID);

            edge.UserData = this.GroupInstance;
        }