Example #1
0
        /// <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);
            }
        }
Example #2
0
        /// <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);
            }
        }
Example #3
0
        /// <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);
            }
        }
Example #4
0
        /// <summary>
        /// Finds and returns all paths starting from node 'from' and
        /// ending at node 'to'. Returns empty collection if no
        /// path exists.
        /// </summary>
        public PathCollection FindAllPaths(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.PathList paths =
                MindFusion.LayoutSystem.PathFinder.FindAllPaths(graph, fromNode, toNode);

            return(new PathCollection(paths));
        }