/// <summary> /// Detects whether the specified node participates in a cycle. /// </summary> public Path FindCycle(Node participant) { StraightFactory factory = new StraightFactory(); FCNode participantNode = factory.CreateNode(participant, false, false) as FCNode; foreach (FCNode node in graph.Nodes) { if (node == participantNode) { participantNode = node; break; } } MindFusion.LayoutSystem.Path path = MindFusion.LayoutSystem.PathFinder.FindCycle(graph, participantNode); if (path != null) { return(new Path(path)); } else { return(null); } }
/// <summary> /// Finds the longest path between two nodes. /// Returns null if no path exists. /// </summary> public Path FindLongestPath(Node from, Node to) { FCNode fromNode = null; FCNode toNode = null; foreach (FCNode node in graph.Nodes) { if (node.Node == from) { fromNode = node; } else if (node.Node == to) { toNode = node; } } MindFusion.LayoutSystem.Path path = MindFusion.LayoutSystem.PathFinder.FindLongestPath(graph, fromNode, toNode); if (path != null) { return(new Path(path)); } else { return(null); } }
/// <summary> /// Finds and returns the shortest path between from and to, /// considering the weight of the nodes, the weight of the /// links or both. /// </summary> public Path FindShortestPath(Node from, Node to, bool useNodeWeights, bool useLinkWeights) { FCNode fromNode = null; FCNode toNode = null; foreach (FCNode node in graph.Nodes) { if (node.Node == from) { fromNode = node; } else if (node.Node == to) { toNode = node; } } MindFusion.LayoutSystem.Path path = MindFusion.LayoutSystem.PathFinder.FindShortestPath( graph, fromNode, toNode, useNodeWeights, useLinkWeights); if (path != null) { return(new Path(path)); } else { return(null); } }
internal Path(MindFusion.LayoutSystem.Path path) { _nodes = new ChartObjectCollection(); _links = new ArrowCollection(); _items = new ChartObjectCollection(); foreach (FCNode node in path.Nodes) { _nodes.Add(node.Node); } foreach (FCLink link in path.Links) { _links.Add(link.Arrow); } foreach (object item in path.Items) { if (item is FCLink) { _items.Add((item as FCLink).Arrow); } else { _items.Add((item as FCNode).Node); } } }
/// <summary> /// Detects whether there is a cycle in a graph. /// </summary> public Path FindCycle() { MindFusion.LayoutSystem.Path path = MindFusion.LayoutSystem.PathFinder.FindCycle(graph); if (path != null) { return(new Path(path)); } else { return(null); } }
/// <summary> /// Finds the longest path in the diagram. The time limit /// specifies the maximum duration of the search process in /// milliseconds. /// Returns null if no path is found. /// </summary> public Path FindLongestPath(long timeLimit) { MindFusion.LayoutSystem.Path path = MindFusion.LayoutSystem.PathFinder.FindLongestPath(graph, timeLimit); if (path != null) { return(new Path(path)); } else { return(null); } }