/// <summary>
        /// Checks if a given graph is planar.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="graph">Undirected graph.</param>
        /// <returns></returns>
        public bool IsPlanar <T>(IGraph <T> graph)
        {
            if (graph.IsDirected)
            {
                throw new ArgumentException("The graph must not be directed", nameof(graph));
            }

            if (graph.VerticesCount == 0)
            {
                return(true);
            }

            var alias = new IntGraph <T>(graph, () => new UndirectedAdjacencyListGraph <int>());

            // Prepare edges for the C++ code
            var edges = new List <int>();

            foreach (var edge in alias.Edges)
            {
                edges.Add(edge.From);
                edges.Add(edge.To);
            }

            return(BoostWrapper.IsPlanar(edges.ToArray(), edges.Count, alias.VerticesCount));
        }
        private int[][] GetFaces(int verticesCount, List <Tuple <int, int> > edges)
        {
            var edgesSerialized = new int[edges.Count * 2];

            for (var i = 0; i < edges.Count; i++)
            {
                var edge = edges[i];
                edgesSerialized[2 * i]     = edge.Item1;
                edgesSerialized[2 * i + 1] = edge.Item2;
            }

            var faces        = new int[2 * edges.Count];
            var facesBorders = new int[2 * edges.Count];

            var success = BoostWrapper.GetFaces(edgesSerialized, edgesSerialized.Length, verticesCount, faces, facesBorders, out var facesCount);

            if (!success)
            {
                return(null);
            }

            var result  = new int[facesCount][];
            var counter = 0;

            for (var i = 0; i < facesCount; i++)
            {
                result[i] = new int[facesBorders[i]];

                for (var j = 0; j < facesBorders[i]; j++)
                {
                    result[i][j] = faces[counter++];
                }
            }

            return(result);
        }