예제 #1
0
        public EdgeList matchingStringsToEdgeList(BipartiteGraph G, List <string> M_String)
        {
            var       M_to_EdgeListM = new EdgeList();
            GraphNode nd1, nd2;

            foreach (string edg in M_String)
            {
                nd1 = G.GetNode(edg.Split('-')[0]);
                nd2 = G.GetNode(edg.Split('-')[1]);
                if (G.Contains(nd1, nd2))
                {
                    M_to_EdgeListM.Add(G.Edges.FindByNodes(nd1, nd2));
                }
                else if (G.Contains(nd2, nd1))
                {
                    M_to_EdgeListM.Add(G.Edges.FindByNodes(nd2, nd1));
                }
                //else
                //{
                //    M_to_EdgeListM.Add(new Edge(nd1,nd2,0));
                //}
            }

            return(M_to_EdgeListM);
        }
        private Edge GetEdgeInPathNotInM(BipartiteGraph G, MatchingList M, MatchingList path)
        {
            Edge   e    = null;
            string edge = path.Except(M).ToList()[0];

            string[]  nodes = edge.Split('-');
            GraphNode node1 = G.GetNode(nodes[0]);
            GraphNode node2 = G.GetNode(nodes[1]);

            if (G.Contains(node1, node2))
            {
                e = G.Edges.FindByNodes(node1, node2);
            }
            else if (G.Contains(node2, node1))
            {
                e = G.Edges.FindByNodes(node2, node1);
            }
            return(e);
        }
        private Edge getEdgeInPathNotInM(BipartiteGraph G, List <String> M, List <String> path)
        {
            Edge   e       = null;
            String eString = path.Except(M).ToList()[0];

            String[]  eNodes = eString.Split('-');
            GraphNode nd1    = G.GetNode(eNodes[0]);
            GraphNode nd2    = G.GetNode(eNodes[1]);

            if (G.Contains(nd1, nd2))
            {
                e = G.Edges.FindByNodes(nd1, nd2);
            }
            else if (G.Contains(nd2, nd1))
            {
                e = G.Edges.FindByNodes(nd2, nd1);
            }
            return(e);
        }
        private EdgeList MatchingToEdgeList(BipartiteGraph G, MatchingList M_String)
        {
            var edgeList = new EdgeList();

            foreach (string edg in M_String)
            {
                GraphNode node1 = G.GetNode(edg.Split('-')[0]);
                GraphNode node2 = G.GetNode(edg.Split('-')[1]);
                if (G.Contains(node1, node2))
                {
                    edgeList.Add(G.Edges.FindByNodes(node1, node2));
                }
                else if (G.Contains(node2, node1))
                {
                    edgeList.Add(G.Edges.FindByNodes(node2, node1));
                }
                //else
                //{
                //    M_to_EdgeListM.Add(new Edge(nd1,nd2,0));
                //}
            }

            return(edgeList);
        }
예제 #5
0
        private static BipartiteGraph G_minus_e(BipartiteGraph G, Edge e)
        {//YHB: this method find the graph G_minus by deleting given edge-e from the G i.e. given graph
            BipartiteGraph G_minus = G;

            if (G.Contains(G.GetNode(e.FromNode.Value), G.GetNode(e.ToNode.Value)))
            {
                G_minus.RemoveDirectedEdge(G.GetNode(e.FromNode.Value), G.GetNode(e.ToNode.Value));
            }
            else
            {
                G_minus.RemoveDirectedEdge(G.GetNode(e.ToNode.Value), G.GetNode(e.FromNode.Value));
            }


            return(G_minus);
        }
        //YHB: this method find the graph G_minus by deleting given edge-e from the G i.e. given graph
        private static BipartiteGraph BuildGminus(BipartiteGraph G, Edge e)
        {
            BipartiteGraph Gminus = G.Clone();
            GraphNode      from   = G.GetNode(e.FromNode.Value);
            GraphNode      to     = G.GetNode(e.ToNode.Value);

            if (G.Contains(from, to))
            {
                Gminus.RemoveDirectedEdge(from, to);
            }
            else
            {
                Gminus.RemoveDirectedEdge(to, from);
            }


            return(Gminus);
        }