public virtual object Clone() { NodeCollection result = new NodeCollection(); foreach (INode node in List) result.Add(node); return result; }
/// <summary> /// Divides the supplied graph to its connected subgraphs. /// </summary> public static IGraph[] Split(IGraph initial, IGraphBuilder builder) { // A list with the nodes awaiting to be processed NodeCollection nodes = initial.Nodes.Clone() as NodeCollection; // A list with the subgraphs IGraph subgraph = null; ArrayList subgraphs = new ArrayList(); while (nodes.Count > 0) { INode node = nodes[0]; nodes.RemoveAt(0); subgraph = builder.Create(); subgraph.Nodes.Add(node); int i = 0; while (i < subgraph.Nodes.Count) { node = subgraph.Nodes[i]; foreach (ILink link in node.InLinks) { if (!subgraph.Nodes.Contains(link.Origin)) { subgraph.Nodes.Add(link.Origin); nodes.Remove(link.Origin); } if (!subgraph.Links.Contains(link)) { subgraph.Links.Add(link); } } foreach (ILink link in node.OutLinks) { if (!subgraph.Nodes.Contains(link.Destination)) { subgraph.Nodes.Add(link.Destination); nodes.Remove(link.Destination); } if (!subgraph.Links.Contains(link)) { subgraph.Links.Add(link); } } i++; } subgraphs.Add(subgraph); } IGraph[] result = new IGraph[subgraphs.Count]; for (int i = 0; i < subgraphs.Count; i++) { result[i] = subgraphs[i] as IGraph; } return(result); }
private void Build(bool keepGroups, bool ignoreArrowDirection) { IFactory factory = CreateFactory(); // Collect nodes _nodes = new NodeCollection(); // Traverse all boxes foreach (Box b in _chart.Boxes) { // Ignore non-layoutable nodes if (b.Frozen) continue; if (keepGroups) { // Add only masters if (b.MasterGroup == null || b.MasterGroup.MainObject is Arrow) _nodes.Add(factory.CreateNode(b, keepGroups, ignoreArrowDirection)); } else { _nodes.Add(factory.CreateNode(b, keepGroups, ignoreArrowDirection)); } } foreach (ControlHost h in _chart.ControlHosts) { // Ignore non-layoutable nodes if (h.Frozen) continue; if (keepGroups) { // Add only masters if (h.MasterGroup == null || h.MasterGroup.MainObject is Arrow) _nodes.Add(factory.CreateNode(h, keepGroups, ignoreArrowDirection)); } else { _nodes.Add(factory.CreateNode(h, keepGroups, ignoreArrowDirection)); } } // Traverse all tables foreach (Table t in _chart.Tables) { // Ignore non-layoutable nodes if (t.Frozen) continue; if (keepGroups) { if (t.MasterGroup == null || t.MasterGroup.MainObject is Arrow) _nodes.Add(factory.CreateNode(t, keepGroups, ignoreArrowDirection)); } else { _nodes.Add(factory.CreateNode(t, keepGroups, ignoreArrowDirection)); } } // Collect links _links = factory.Links; }
/// <summary> /// Constructs an empty graph. /// </summary> public FCGraph(FlowChart chart) { _chart = chart; directed = true; _nodes = new NodeCollection(); _links = new LinkCollection(); }
public Path() { _nodes = new NodeCollection(); _links = new LinkCollection(); _items = new ArrayList(); }
public Path() { _nodes = new NodeCollection(); _links = new LinkCollection(); _items = new ArrayList(); }