Esempio n. 1
0
 public Edge FindEdge(Node start, Node end)
 {
     foreach (Edge edge in Edges.Where(x => x.Active))
         if (start.Equals(edge.StartNode) && end.Equals(edge.EndNode))
             return edge;
     return null;
 }
Esempio n. 2
0
        public void AddToLayer(Node n, int currentLayer)
        {
            while (Layers.Count <= currentLayer)
                Layers.Add(new List<Node>());

            Layers[currentLayer].Add(n);
            n.Layer = currentLayer;
        }
Esempio n. 3
0
 /// <summary>
 /// Finds an active edge between two nodes.
 /// </summary>
 /// <param name="start">Start node.</param>
 /// <param name="end">End node.</param>
 /// <returns>The edge object.</returns>
 public Edge FindEdge(Node start, Node end)
 {
     foreach (Edge edge in Edges)
     {
         if (edge.Active && start.Equals(edge.StartNode) && end.Equals(edge.EndNode))
         {
             return edge;
         }
     }
     return null;
 }
Esempio n. 4
0
        public Edge(Guid startId, Guid endId, double startX, double startY, double endX, double endY, Graph ownerGraph)
        {
            StartX = startX;
            StartY = startY;
            EndX = endX;
            EndY = endY;
            OwnerGraph = ownerGraph;

            StartNode = OwnerGraph.FindNode(startId);
            if (StartNode != null)
            {
                StartNode.RightEdges.Add(this);
            }

            EndNode = OwnerGraph.FindNode(endId);
            if (EndNode != null)
            {
                EndNode.LeftEdges.Add(this);
            }

            StartOffsetY = startY - StartNode.Y;
            EndOffsetY = endY - EndNode.Y;
        }
Esempio n. 5
0
 /// <summary>
 /// Adds a new node to the graph object.
 /// </summary>
 /// <param name="guid">The guid as a unique identifier of the node.</param>
 /// <param name="width">The width of the node view.</param>
 /// <param name="height">The height of the node view.</param>
 /// <param name="x">The x coordinate of the node view.</param>
 /// <param name="y">The y coordinate of the node view.</param>
 /// <param name="inPortCount">The number of input ports of the node.</param>
 public void AddNode(Guid guid, double width, double height, double x, double y)
 {
     var node = new Node(guid, width, height, x, y, this);
     Nodes.Add(node);
 }
Esempio n. 6
0
 /// <summary>
 /// Adds a new node to the graph object.
 /// </summary>
 /// <param name="guid">The guid as a unique identifier of the node.</param>
 /// <param name="width">The width of the node view.</param>
 /// <param name="height">The height of the node view.</param>
 /// <param name="y">The y coordinate of the node view.</param>
 /// <param name="inPortCount">The number of input ports of the node.</param>
 public void AddNode(Guid guid, double width, double height, double y, int inPortCount = 0)
 {
     var node = new Node(guid, width, height, y, this);
     node.InPortCount = inPortCount;
     Nodes.Add(node);
 }
Esempio n. 7
0
 /// <summary>
 /// Adds a new node to the graph object.
 /// </summary>
 /// <param name="guid">The guid as a unique identifier of the node.</param>
 /// <param name="width">The width of the node view.</param>
 /// <param name="height">The height of the node view.</param>
 /// <param name="x">The x coordinate of the node view.</param>
 /// <param name="y">The y coordinate of the node view.</param>
 /// <param name="isSelected">True if the node is selected in the workspace.</param>
 public void AddNode(Guid guid, double width, double height, double x, double y, bool isSelected)
 {
     var node = new Node(guid, width, height, x, y, isSelected, this);
     Nodes.Add(node);
 }