예제 #1
0
        public virtual object Clone()
        {
            LinkCollection result = new LinkCollection();

            foreach (ILink link in List)
            {
                result.Add(link);
            }

            return(result);
        }
예제 #2
0
		public virtual object Clone()
		{
			LinkCollection result = new LinkCollection();

			foreach (ILink link in List)
				result.Add(link);

			return result;
		}
예제 #3
0
		/// <summary>
		/// Constructs an empty graph.
		/// </summary>
		public FCGraph(FlowChart chart)
		{
			_chart = chart;
			directed = true;

			_nodes = new NodeCollection();
			_links = new LinkCollection();
		}
예제 #4
0
		private LinkCollection GetInLinks(IFactory factory)
		{
			LinkCollection links = new LinkCollection();

			ChartObjectCollection nodes = new ChartObjectCollection();
			nodes.Add(_node);

			// Collect all objects within that group
			if (_keepGroups)
			{
				int i = 0;
				while (i < nodes.Count)
				{
					Node node = nodes[i] as Node;
					i++;

					if (node.SubordinateGroup != null)
					{
						foreach (ChartObject sub in node.SubordinateGroup.AttachedObjects)
						{
							// Check if attached object is a node
							if (!(sub is Node))
								continue;

							// Add the node to the nodes of the group
							if (!nodes.Contains(sub))
								nodes.Add(sub);
						}
					}
				}
			}

			foreach (Node node in nodes)
			{
				foreach (Arrow a in node.IncomingArrows)
				{
					// Ignore non-layoutable objects
					if (a.IgnoreLayout)
						continue;
					if (a.Origin.Frozen)
						continue;
					if (!a.IsConnected)
						continue;

					// Add only if it comes from outside the group
					if (!nodes.Contains(a.Origin))
					{
						// Use the factory to create the adapter link.
						// That way, if the adapter for the arrow already
						// exists, it will be returned instead of creating a
						// new adapter.
						links.Add(factory.CreateLink(a,
							_keepGroups, _ignoreArrowDirection));
					}
				}

				if (node is Table)
				{
					Table t = node as Table;

					foreach (Table.Row r in t.Rows)
					{
						foreach (Arrow a in r.IncomingArrows)
						{
							// Ignore non-layoutable objects
							if (a.IgnoreLayout)
								continue;
							if (a.Origin.Frozen)
								continue;
							if (!a.IsConnected)
								continue;

							// Add only if it comes from outside the group
							if (!nodes.Contains(a.Origin))
							{
								// Use the factory to create the adapter link.
								// That way, if the adapter for the arrow already
								// exists, it will be returned instead of creating a
								// new adapter.
								links.Add(factory.CreateLink(a,
									_keepGroups, _ignoreArrowDirection));
							}
						}
					}
				}
			}

			return links;
		}
예제 #5
0
		public void Create(Node node, bool keepGroups,
			bool ignoreArrowDirection, IFactory factory)
		{
			_node = node;
			_keepGroups = keepGroups;
			_ignoreArrowDirection = ignoreArrowDirection;

			// If groups' layout is preserved, then, the underlying
			// node is always the highest-in-hierarchy group master.
			if (_keepGroups)
			{
				while (node.MasterGroup != null)
				{
					if (!(node.MasterGroup.MainObject is Node))
						break;

					node = node.MasterGroup.MainObject as Node;
				}

				_node = node;
			}

			// Enumerate incoming and outgoing links
			_inLinks = GetInLinks(factory);
			_outLinks = GetOutLinks(factory);
			_allLinks = new LinkCollection();
			_allLinks.AddRange(_inLinks);
			_allLinks.AddRange(_outLinks);
		}
예제 #6
0
파일: Path.cs 프로젝트: ChrisMoreton/Test3
		public Path()
		{
			_nodes = new NodeCollection();
			_links = new LinkCollection();
			_items = new ArrayList();
		}
예제 #7
0
파일: Path.cs 프로젝트: 15831944/Test3-1
        private static PathList FindPaths(IGraph graph,
                                          INode from, INode to, bool shortestOnly)
        {
            PathList result = new PathList();
            Path     path   = null;

            if (from == to && shortestOnly)
            {
                // Return a collection with a single path consisting of a single node.
                path = new Path();
                path.Add(from);
                result.Add(path);

                return(result);
            }

            // Perform the search
            PathList tempCol = new PathList();
            Path     tempPath;

            // Create the first path, constisting only of the first node
            tempCol.Add(tempPath = new Path());
            tempPath.Add(from);

            bool pathFound = false;

            while (true)
            {
                int size = tempCol.Count;
                if (size == 0)
                {
                    break;
                }
                if (pathFound && shortestOnly)
                {
                    break;
                }

                // For all paths - get their next nodes
                for (int i = 0; i < size; i++)
                {
                    tempPath = tempCol[0];
                    tempCol.RemoveAt(0);

                    // Get the last node for this path and find its successors
                    INode          lastNode = tempPath.Nodes[tempPath.Nodes.Count - 1];
                    LinkCollection links    = lastNode.OutLinks;
                    foreach (ILink link in links)
                    {
                        INode nextNode;

                        // Get the next node in the path
                        nextNode = graph.Directed ?
                                   link.Destination : link.GetOppositeNode(lastNode);

                        // Check if the path target is reached
                        if (nextNode.Equals(to))
                        {
                            // We've reached the end
                            Path newPath = new Path(tempPath);
                            newPath.Add(link, nextNode);
                            result.Add(newPath);
                            pathFound = true;
                            continue;
                        }

                        // The node does not belong to the path -> add it
                        if (!tempPath.Contains(nextNode))
                        {
                            Path newPath = new Path(tempPath);
                            newPath.Add(link, nextNode);
                            tempCol.Add(newPath);
                        }
                    }
                }
            }

            return(result);
        }
예제 #8
0
파일: Path.cs 프로젝트: 15831944/Test3-1
 public Path()
 {
     _nodes = new NodeCollection();
     _links = new LinkCollection();
     _items = new ArrayList();
 }