Esempio n. 1
0
        public static SimpleGraph CreateGraph(Topology topology)
        {
            var nodeCount  = topology.IndexCount;
            var neighbours = new int[nodeCount][];

            for (int i = 0; i < nodeCount; i++)
            {
                if (!topology.ContainsIndex(i))
                {
                    neighbours[i] = Emtpy;
                }

                var n = new List <int>();
                foreach (var d in topology.Directions)
                {
                    if (topology.TryMove(i, d, out var dest))
                    {
                        n.Add(dest);
                    }
                }
                neighbours[i] = n.ToArray();
            }

            return(new SimpleGraph
            {
                NodeCount = nodeCount,
                Neighbours = neighbours,
            });
        }