Exemple #1
0
        /// <summary>
        /// Splits the given list of elements
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private static List <List <int> > Split(List <List <int> > list, Dart d)
        {
            List <List <int> > result = new List <List <int> >();

            for (int k = 0; k < list.Count; k++)
            {
                var f     = list[k];
                var pairs = ListPairs(f);

                if (!pairs.Contains(d))
                {
                    result.Add(f);
                    continue;
                }

                int i = pairs.IndexOf(d);
                f = f.rotate(i - 1);

                if (f.Count <= 3)
                {
                    result.Add(f);
                }
                else
                {
                    var f2 = f.Skip(2).ToList();
                    f2.Insert(0, f[0]);

                    result.Add(f.Take(3).ToList());
                    result.Add(f2);
                }

                for (k++; k < list.Count; k++)
                {
                    result.Add(list[k]);
                }

                break;
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Splits the given list of elements
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private static List<List<int>> Split(List<List<int>> list, Dart d)
        {
            List<List<int>> result = new List<List<int>>();

            for (int k = 0; k < list.Count; k++)
            {
                var f = list[k];
                var pairs = ListPairs(f);

                if (!pairs.Contains(d))
                {
                    result.Add(f);
                    continue;
                }

                int i = pairs.IndexOf(d);
                f = f.rotate(i - 1);

                if (f.Count <= 3)
                {
                    result.Add(f);
                }
                else
                {
                    var f2 = f.Skip(2).ToList();
                    f2.Insert(0, f[0]);

                    result.Add(f.Take(3).ToList());
                    result.Add(f2);
                }

                for (k++; k < list.Count; k++)
                {
                    result.Add(list[k]);
                }

                break;
            }

            return result;
        }
Exemple #3
0
        /// <summary>
        /// Computes all sets of darts
        /// </summary>
        public void ComputeAllSets(List<int> facesPermutation)
        {
            // faces
            var faces = list.map(l => ListPairs(l));
            var faces3 = faces.filter(f => f.Count == 3);
            var faces4 = faces.filter(f => f.Count == 4);
            var faces5 = faces.filter(f => f.Count == 5);
            var faces6 = faces.filter(f => f.Count == 6);

            // darts
            var darts = faces.flatten();
            var darts3 = faces3.flatten();
            var darts4 = faces4.flatten();
            var darts5 = faces5.flatten();
            var darts6 = faces6.flatten();

            // edges
            var edges = darts.map(d => new List<Dart>(new Dart[] {d, new Dart(d.b, d.a)} ));

            // dartPairs
            var dartPairs = darts.map(x => darts.map(y => new List<Dart>(new Dart[] { x, y }))).flatten();

            // nodes
            var elements = list.flatten().removeDuplicates();
            var nodes = elements.map(x => darts.filter(d => d.a == x));

            // Add everything to the collection of all sets
            sets = new Dictionary<string, List<HypermapElement>>();

            sets.Add("faces", faces.ToHypermapElements());
            sets.Add("darts", darts.ToHypermapElements());
            sets.Add("edges", edges.ToHypermapElements());
            sets.Add("nodes", nodes.ToHypermapElements());
            sets.Add("darts3", darts3.ToHypermapElements());
            sets.Add("darts4", darts4.ToHypermapElements());
            sets.Add("darts5", darts5.ToHypermapElements());
            sets.Add("darts6", darts6.ToHypermapElements());
            sets.Add("faces3", faces3.ToHypermapElements());
            sets.Add("faces4", faces4.ToHypermapElements());
            sets.Add("faces5", faces5.ToHypermapElements());
            sets.Add("faces6", faces6.ToHypermapElements());
            sets.Add("dart_pairs", dartPairs.ToHypermapElements());

            // Create the translation tables
            translationTables = new Dictionary<string, Dictionary<string, HypermapElement>>();

            // e_darts, faces, darts
            Dictionary<string, HypermapElement> e_darts = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_faces = new Dictionary<string,HypermapElement>();
            Dictionary<string, HypermapElement> mod_face3_darts = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_face4_darts = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_face5_darts = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_face6_darts = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_darts = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_edartPairs = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_dartPairsFst = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_edartPairsFst = new Dictionary<string, HypermapElement>();

            for (int j = 0; j < list.Count; j++)
            {
                int mod_index = facesPermutation[j];
                var f = list[j];
                int n = f.Count;
                for (int i = 0; i < n; i++)
                {
                    int i1 = f[i];
                    int i2 = f[(i + 1) % n];
                    int i3 = f[(i + 2) % n];
                    string e_dart = i1 + "," + i2 + "," + i3 + "," + mod_index;
                    string dart = i2 + "," + mod_index;
                    HypermapElement d = new Dart(i2, i3);

                    // (i1,i2,i3,j) corresponds to (i2,i3); (i1,j) = f^(-1)(i2,j) and (i3,j) = f(i2,j)
                    e_darts.Add(e_dart, d);
                    mod_darts.Add(dart, d);
                }

                mod_faces.Add(mod_index.ToString(), new DartList(faces[j]));

                var mod_face_darts = mod_face3_darts;
                switch (n)
                {
                    case 3:
                        mod_face_darts = mod_face3_darts;
                        break;
                    case 4:
                        mod_face_darts = mod_face4_darts;
                        break;
                    case 5:
                        mod_face_darts = mod_face5_darts;
                        break;
                    case 6:
                        mod_face_darts = mod_face6_darts;
                        break;
                    default:
                        throw new Exception(String.Format("Unexpected face size {0}", n));
                }

                mod_face_darts.Add(mod_index.ToString(), faces[j][0]);
            }

            // extended dart pairs
            foreach (string e_dart1 in e_darts.Keys)
            {
                var dart1 = e_darts[e_dart1] as Dart;

                foreach (string e_dart2 in e_darts.Keys)
                {
                    var dart2 = e_darts[e_dart2] as Dart;
                    String e_pair = e_dart1 + "," + e_dart2;
                    DartList pair = new DartList(dart1, dart2);
                    mod_edartPairs.Add(e_pair, pair);
                    mod_edartPairsFst.Add(e_pair, dart1);
                }
            }

            // dart pairs
            foreach (string dart1 in mod_darts.Keys)
            {
                Dart d1 = mod_darts[dart1] as Dart;

                foreach (string dart2 in mod_darts.Keys)
                {
                    String dart_pair = dart1 + "," + dart2;
                    mod_dartPairsFst.Add(dart_pair, d1);
                }
            }

            // nodes
            Dictionary<string, HypermapElement> mod_nodes = new Dictionary<string, HypermapElement>();
            foreach (int x in elements)
            {
                mod_nodes.Add(x.ToString(), new DartList(darts.filter(d => d.a == x)));
            }

            // edges
            Dictionary<string, HypermapElement> mod_edges = new Dictionary<string, HypermapElement>();
            foreach (var e in edges)
            {
                Dart d1 = e[0];
                Dart d2 = e[1];
                int i1 = d1.a;
                int j1 = facesPermutation[FindFaceIndex(d1.a, d1.b)];

                int i2 = d2.a;
                int j2 = facesPermutation[FindFaceIndex(d2.a, d2.b)];

                string edge = i1 + "," + j1 + "," + i2 + "," + j2;
                mod_edges.Add(edge, new DartList(e));
            }

            // Add everything into the global table
            translationTables.Add("e_dart", e_darts);
            translationTables.Add("dart", mod_darts);
            translationTables.Add("edge", mod_edges);
            translationTables.Add("face", mod_faces);
            translationTables.Add("node", mod_nodes);
            translationTables.Add("face3_dart", mod_face3_darts);
            translationTables.Add("face4_dart", mod_face4_darts);
            translationTables.Add("face5_dart", mod_face5_darts);
            translationTables.Add("face6_dart", mod_face6_darts);
            translationTables.Add("dart_pairs_fst", mod_dartPairsFst);
            translationTables.Add("e_dart_pairs", mod_edartPairs);
            translationTables.Add("e_dart_pairs_fst", mod_edartPairsFst);
        }
Exemple #4
0
        /// <summary>
        /// Computes all sets of darts
        /// </summary>
        public void ComputeAllSets()
        {
            // faces
            var faces  = list.map(l => ListPairs(l));
            var faces3 = faces.filter(f => f.Count == 3);
            var faces4 = faces.filter(f => f.Count == 4);
            var faces5 = faces.filter(f => f.Count == 5);
            var faces6 = faces.filter(f => f.Count == 6);

            // darts
            var darts  = faces.flatten();
            var darts3 = faces3.flatten();
            var darts4 = faces4.flatten();
            var dartsX = faces.filter(f => f.Count >= 4).flatten();

            // edges
            var edges = darts.map(d => new List <Dart>(new Dart[] { d, new Dart(d.b, d.a) }));

            // nodes
            var elements = list.flatten().removeDuplicates();
            var nodes    = elements.map(x => darts.filter(d => d.a == x));


            // Add everything to the collection of all sets
            sets = new Dictionary <string, List <HypermapElement> >();

            sets.Add("faces", faces.ToHypermapElements());
            sets.Add("darts", darts.ToHypermapElements());
            sets.Add("edges", edges.ToHypermapElements());
            sets.Add("nodes", nodes.ToHypermapElements());
            sets.Add("darts3", darts3.ToHypermapElements());
            sets.Add("darts4", darts4.ToHypermapElements());
            sets.Add("dartsX", dartsX.ToHypermapElements());
            sets.Add("faces3", faces3.ToHypermapElements());
            sets.Add("faces4", faces4.ToHypermapElements());
            sets.Add("faces5", faces5.ToHypermapElements());
            sets.Add("faces6", faces6.ToHypermapElements());

            // Special names
            sets.Add("dart_std4", sets["darts4"]);
            sets.Add("dart3", sets["darts3"]);
            sets.Add("dart_std3", sets["darts3"]);
            sets.Add("dart_std", sets["darts"]);
            sets.Add("std3", sets["faces3"]);
            sets.Add("std4", sets["faces4"]);
            sets.Add("std5", sets["faces5"]);
            sets.Add("std6", sets["faces6"]);
            sets.Add("dartX", sets["dartsX"]);

            // Create the translation tables
            translationTables = new Dictionary <string, Dictionary <string, HypermapElement> >();

            // e_darts, faces, darts
            Dictionary <string, HypermapElement> e_darts   = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_faces = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_darts = new Dictionary <string, HypermapElement>();

            for (int j = 0; j < list.Count; j++)
            {
                var f = list[j];
                int n = f.Count;
                for (int i = 0; i < n; i++)
                {
                    int             i1     = f[i];
                    int             i2     = f[(i + 1) % n];
                    int             i3     = f[(i + 2) % n];
                    string          e_dart = i1 + "," + i2 + "," + i3 + "," + j;
                    string          dart   = i2 + "," + j;
                    HypermapElement d      = new Dart(i2, i3);

                    e_darts.Add(e_dart, d);
                    mod_darts.Add(dart, d);
                }

                mod_faces.Add(j.ToString(), new DartList(faces[j]));
            }

            // nodes
            Dictionary <string, HypermapElement> mod_nodes = new Dictionary <string, HypermapElement>();

            foreach (int x in elements)
            {
                mod_nodes.Add(x.ToString(), new DartList(darts.filter(d => d.a == x)));
            }

            // edges
            Dictionary <string, HypermapElement> mod_edges = new Dictionary <string, HypermapElement>();

            foreach (var e in edges)
            {
                Dart d1 = e[0];
                Dart d2 = e[1];
                int  i1 = d1.a;
                int  j1 = FindFaceIndex(d1.a, d1.b);

                int i2 = d2.a;
                int j2 = FindFaceIndex(d2.a, d2.b);

                string edge = i1 + "," + j1 + "," + i2 + "," + j2;
                mod_edges.Add(edge, new DartList(e));
            }


            // Add everything into the global table
            translationTables.Add("e_dart", e_darts);
            translationTables.Add("dart", mod_darts);
            translationTables.Add("edge", mod_edges);
            translationTables.Add("face", mod_faces);
            translationTables.Add("node", mod_nodes);
        }
Exemple #5
0
        /// <summary>
        /// Computes a hypermap from input file data
        /// </summary>
        /// <param name="hypInfo"></param>
        /// <returns></returns>
        public ListHyp ComputeHypermap(TextReader hypInfo, out string name, out bool infeasible)
        {
            name       = null;
            infeasible = false;
            string             id               = null;
            List <List <int> > hypList          = null;
            List <Dart>        splitDarts       = new List <Dart>();
            List <int>         facesPermutation = null;

            while (true)
            {
                string str = hypInfo.ReadLine();
                if (str == null)
                {
                    break;
                }

                string[] els = str.Split(':');
                if (els.Length != 2)
                {
                    Console.WriteLine("Bad line: " + str);
                    continue;
                }

                string val = els[1].Trim();

                switch (els[0].Trim())
                {
                case "infeasible":
                    infeasible = (val == "true");
                    break;

                case "name":
                    name = val;
                    break;

                case "id":
                    id = val;
                    break;

                case "hypermap":
                    if (val == "")
                    {
                        break;
                    }

                    hypList = new List <List <int> >();
                    els     = val.Split(';');
                    foreach (string el in els)
                    {
                        List <int> f = el.Split(',').ToList().map(x => int.Parse(x));
                        hypList.Add(f);
                    }

                    break;

                case "split":
                    if (val == "")
                    {
                        break;
                    }

                    els = val.Split(';');
                    splitDarts.Clear();

                    foreach (string el in els)
                    {
                        splitDarts.Add(Dart.Parse(el));
                    }
                    break;

                case "faces":
                    facesPermutation = val.Split(',').ToList().map(x => int.Parse(x));
                    break;

                default:
                    Console.WriteLine("Bad line: " + str);
                    break;
                }
            }

            if (name == null || facesPermutation == null)
            {
                throw new Exception("ComputeHypermaps(): name or facesPermutation are not defined");
            }

            if (id == null && hypList == null)
            {
                throw new Exception("ComputeHypermaps(): both id and hypList are not defined");
            }

            ListHyp hyp = null;

            if (hypList != null)
            {
                hyp = new ListHyp(hypList, this).Split(splitDarts);
            }
            else
            {
                hyp = this[id].Split(splitDarts);
            }

            hyp.ComputeAllSets(facesPermutation);
            return(hyp);
        }
Exemple #6
0
        /// <summary>
        /// Computes all sets of darts
        /// </summary>
        public void ComputeAllSets(List <int> facesPermutation)
        {
            // faces
            var faces  = list.map(l => ListPairs(l));
            var faces3 = faces.filter(f => f.Count == 3);
            var faces4 = faces.filter(f => f.Count == 4);
            var faces5 = faces.filter(f => f.Count == 5);
            var faces6 = faces.filter(f => f.Count == 6);

            // darts
            var darts  = faces.flatten();
            var darts3 = faces3.flatten();
            var darts4 = faces4.flatten();
            var darts5 = faces5.flatten();
            var darts6 = faces6.flatten();

            // edges
            var edges = darts.map(d => new List <Dart>(new Dart[] { d, new Dart(d.b, d.a) }));

            // dartPairs
            var dartPairs = darts.map(x => darts.map(y => new List <Dart>(new Dart[] { x, y }))).flatten();

            // nodes
            var elements = list.flatten().removeDuplicates();
            var nodes    = elements.map(x => darts.filter(d => d.a == x));


            // Add everything to the collection of all sets
            sets = new Dictionary <string, List <HypermapElement> >();

            sets.Add("faces", faces.ToHypermapElements());
            sets.Add("darts", darts.ToHypermapElements());
            sets.Add("edges", edges.ToHypermapElements());
            sets.Add("nodes", nodes.ToHypermapElements());
            sets.Add("darts3", darts3.ToHypermapElements());
            sets.Add("darts4", darts4.ToHypermapElements());
            sets.Add("darts5", darts5.ToHypermapElements());
            sets.Add("darts6", darts6.ToHypermapElements());
            sets.Add("faces3", faces3.ToHypermapElements());
            sets.Add("faces4", faces4.ToHypermapElements());
            sets.Add("faces5", faces5.ToHypermapElements());
            sets.Add("faces6", faces6.ToHypermapElements());
            sets.Add("dart_pairs", dartPairs.ToHypermapElements());

            // Create the translation tables
            translationTables = new Dictionary <string, Dictionary <string, HypermapElement> >();

            // e_darts, faces, darts
            Dictionary <string, HypermapElement> e_darts           = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_faces         = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_face3_darts   = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_face4_darts   = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_face5_darts   = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_face6_darts   = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_darts         = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_edartPairs    = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_dartPairsFst  = new Dictionary <string, HypermapElement>();
            Dictionary <string, HypermapElement> mod_edartPairsFst = new Dictionary <string, HypermapElement>();

            for (int j = 0; j < list.Count; j++)
            {
                int mod_index = facesPermutation[j];
                var f         = list[j];
                int n         = f.Count;
                for (int i = 0; i < n; i++)
                {
                    int             i1     = f[i];
                    int             i2     = f[(i + 1) % n];
                    int             i3     = f[(i + 2) % n];
                    string          e_dart = i1 + "," + i2 + "," + i3 + "," + mod_index;
                    string          dart   = i2 + "," + mod_index;
                    HypermapElement d      = new Dart(i2, i3);

                    // (i1,i2,i3,j) corresponds to (i2,i3); (i1,j) = f^(-1)(i2,j) and (i3,j) = f(i2,j)
                    e_darts.Add(e_dart, d);
                    mod_darts.Add(dart, d);
                }

                mod_faces.Add(mod_index.ToString(), new DartList(faces[j]));

                var mod_face_darts = mod_face3_darts;
                switch (n)
                {
                case 3:
                    mod_face_darts = mod_face3_darts;
                    break;

                case 4:
                    mod_face_darts = mod_face4_darts;
                    break;

                case 5:
                    mod_face_darts = mod_face5_darts;
                    break;

                case 6:
                    mod_face_darts = mod_face6_darts;
                    break;

                default:
                    throw new Exception(String.Format("Unexpected face size {0}", n));
                }

                mod_face_darts.Add(mod_index.ToString(), faces[j][0]);
            }

            // extended dart pairs
            foreach (string e_dart1 in e_darts.Keys)
            {
                var dart1 = e_darts[e_dart1] as Dart;

                foreach (string e_dart2 in e_darts.Keys)
                {
                    var      dart2  = e_darts[e_dart2] as Dart;
                    String   e_pair = e_dart1 + "," + e_dart2;
                    DartList pair   = new DartList(dart1, dart2);
                    mod_edartPairs.Add(e_pair, pair);
                    mod_edartPairsFst.Add(e_pair, dart1);
                }
            }

            // dart pairs
            foreach (string dart1 in mod_darts.Keys)
            {
                Dart d1 = mod_darts[dart1] as Dart;

                foreach (string dart2 in mod_darts.Keys)
                {
                    String dart_pair = dart1 + "," + dart2;
                    mod_dartPairsFst.Add(dart_pair, d1);
                }
            }

            // nodes
            Dictionary <string, HypermapElement> mod_nodes = new Dictionary <string, HypermapElement>();

            foreach (int x in elements)
            {
                mod_nodes.Add(x.ToString(), new DartList(darts.filter(d => d.a == x)));
            }

            // edges
            Dictionary <string, HypermapElement> mod_edges = new Dictionary <string, HypermapElement>();

            foreach (var e in edges)
            {
                Dart d1 = e[0];
                Dart d2 = e[1];
                int  i1 = d1.a;
                int  j1 = facesPermutation[FindFaceIndex(d1.a, d1.b)];

                int i2 = d2.a;
                int j2 = facesPermutation[FindFaceIndex(d2.a, d2.b)];

                string edge = i1 + "," + j1 + "," + i2 + "," + j2;
                mod_edges.Add(edge, new DartList(e));
            }


            // Add everything into the global table
            translationTables.Add("e_dart", e_darts);
            translationTables.Add("dart", mod_darts);
            translationTables.Add("edge", mod_edges);
            translationTables.Add("face", mod_faces);
            translationTables.Add("node", mod_nodes);
            translationTables.Add("face3_dart", mod_face3_darts);
            translationTables.Add("face4_dart", mod_face4_darts);
            translationTables.Add("face5_dart", mod_face5_darts);
            translationTables.Add("face6_dart", mod_face6_darts);
            translationTables.Add("dart_pairs_fst", mod_dartPairsFst);
            translationTables.Add("e_dart_pairs", mod_edartPairs);
            translationTables.Add("e_dart_pairs_fst", mod_edartPairsFst);
        }
Exemple #7
0
        /// <summary>
        /// Computes all sets of darts
        /// </summary>
        public void ComputeAllSets()
        {
            // faces
            var faces = list.map(l => ListPairs(l));
            var faces3 = faces.filter(f => f.Count == 3);
            var faces4 = faces.filter(f => f.Count == 4);
            var faces5 = faces.filter(f => f.Count == 5);
            var faces6 = faces.filter(f => f.Count == 6);

            // darts
            var darts = faces.flatten();
            var darts3 = faces3.flatten();
            var darts4 = faces4.flatten();
            var dartsX = faces.filter(f => f.Count >= 4).flatten();

            // edges
            var edges = darts.map(d => new List<Dart>(new Dart[] {d, new Dart(d.b, d.a)} ));

            // nodes
            var elements = list.flatten().removeDuplicates();
            var nodes = elements.map(x => darts.filter(d => d.a == x));

            // Add everything to the collection of all sets
            sets = new Dictionary<string, List<HypermapElement>>();

            sets.Add("faces", faces.ToHypermapElements());
            sets.Add("darts", darts.ToHypermapElements());
            sets.Add("edges", edges.ToHypermapElements());
            sets.Add("nodes", nodes.ToHypermapElements());
            sets.Add("darts3", darts3.ToHypermapElements());
            sets.Add("darts4", darts4.ToHypermapElements());
            sets.Add("dartsX", dartsX.ToHypermapElements());
            sets.Add("faces3", faces3.ToHypermapElements());
            sets.Add("faces4", faces4.ToHypermapElements());
            sets.Add("faces5", faces5.ToHypermapElements());
            sets.Add("faces6", faces6.ToHypermapElements());

            // Special names
            sets.Add("dart_std4", sets["darts4"]);
            sets.Add("dart3", sets["darts3"]);
            sets.Add("dart_std3", sets["darts3"]);
            sets.Add("dart_std", sets["darts"]);
            sets.Add("std3", sets["faces3"]);
            sets.Add("std4", sets["faces4"]);
            sets.Add("std5", sets["faces5"]);
            sets.Add("std6", sets["faces6"]);
            sets.Add("dartX", sets["dartsX"]);

            // Create the translation tables
            translationTables = new Dictionary<string, Dictionary<string, HypermapElement>>();

            // e_darts, faces, darts
            Dictionary<string, HypermapElement> e_darts = new Dictionary<string, HypermapElement>();
            Dictionary<string, HypermapElement> mod_faces = new Dictionary<string,HypermapElement>();
            Dictionary<string, HypermapElement> mod_darts = new Dictionary<string,HypermapElement>();

            for (int j = 0; j < list.Count; j++)
            {
                var f = list[j];
                int n = f.Count;
                for (int i = 0; i < n; i++)
                {
                    int i1 = f[i];
                    int i2 = f[(i + 1) % n];
                    int i3 = f[(i + 2) % n];
                    string e_dart = i1 + "," + i2 + "," + i3 + "," + j;
                    string dart = i2 + "," + j;
                    HypermapElement d = new Dart(i2, i3);

                    e_darts.Add(e_dart, d);
                    mod_darts.Add(dart, d);
                }

                mod_faces.Add(j.ToString(), new DartList(faces[j]));
            }

            // nodes
            Dictionary<string, HypermapElement> mod_nodes = new Dictionary<string, HypermapElement>();
            foreach (int x in elements)
            {
                mod_nodes.Add(x.ToString(), new DartList(darts.filter(d => d.a == x)));
            }

            // edges
            Dictionary<string, HypermapElement> mod_edges = new Dictionary<string, HypermapElement>();
            foreach (var e in edges)
            {
                Dart d1 = e[0];
                Dart d2 = e[1];
                int i1 = d1.a;
                int j1 = FindFaceIndex(d1.a, d1.b);

                int i2 = d2.a;
                int j2 = FindFaceIndex(d2.a, d2.b);

                string edge = i1 + "," + j1 + "," + i2 + "," + j2;
                mod_edges.Add(edge, new DartList(e));
            }

            // Add everything into the global table
            translationTables.Add("e_dart", e_darts);
            translationTables.Add("dart", mod_darts);
            translationTables.Add("edge", mod_edges);
            translationTables.Add("face", mod_faces);
            translationTables.Add("node", mod_nodes);
        }