public static ParityGame ParseDirect(string PGfile)
        {
            var sr = new StreamReader(PGfile);
            var ret = new ParityGame();
            string firstline = sr.ReadLine();

            int numNodes = 1 + int.Parse(firstline.Split(' ')[1].TrimEnd(';'));
            ret.V = new Vertex[numNodes];
            //ret.E = new List<Edge>();
            while (!sr.EndOfStream) {
                string line = sr.ReadLine();
                string[] tokens = line.TrimEnd(';').Split(' ');
                Vertex v = ret.GetV(int.Parse(tokens[0]));
                v.Priority = int.Parse(tokens[1]);
                v.OwnerEven = tokens[2] == "0";
                foreach (var succ in tokens[3].Split(',')) {
                    var w = ret.GetV(int.Parse(succ));
                    //ret.E.Add(new Edge(v, w));
                    v.Adj.Add(w);
                    w.Inc.Add(v);
                }
                if (tokens.Length >= 5)
                    v.Name = tokens[4].Trim('"');
            }
            return ret;
        }
Example #2
0
        public static List<List<Vertex>> DetectCycles(ParityGame g)
        {
            _stronglyConnectedComponents = new List<List<Vertex>>();
            foreach (var v in g.V) v.index = -1;

            index = 0;
            S = new Stack<Vertex>();
            dg = g;
            foreach (Vertex v in g.V) {
                if (v.index < 0) {
                    StrongConnect(v);
                }
            }
            return _stronglyConnectedComponents;
        }
 public Jurdzinsky(ParityGame pg)
 {
     this.pg = pg;
     // determine maximum values for dtuple
     d = pg.V.Max(m => m.Priority) + 1; // d = max{ p(v) | v in V} + 1.
     MMaxEven = new DTuple(d);
     for (int i = 1; i < d; i += 2)
         MMaxEven[i] = pg.V.Count(v => v.Priority == i);
     //MMaxOdd = new DTuple(d);
     //for (int i = 0; i < d; i += 2)
     //	MMaxOdd[i] = pg.V.Count(v => v.Priority == i);
     MTop = new DTuple(d);
     for (int i = 0; i < d; i++)
         MTop[i] = int.MaxValue;
 }
        public static List<List<Vertex>> DetectCycles(ParityGame g)
        {
            _sccs.Clear();
            _tarStack.Clear();
            _onStack.Clear();
            foreach (var v in g.V) v.index = -1;

            int index = 0;
            foreach (var v in g.V)
                _onStack[v] = false;
            for (int n = 0; n < g.V.Length; n++) {
                if (g.V[n].index == -1) {
                    tarjan_iter(g.V[n], ref index);
                }
            }
            return _sccs;
        }