Exemple #1
0
        static void Main(string[] args)
        {
            bool[,] boolMap = GetBoolMapFromTxt(robotMapPath);
            ListGraph <MapElement> robotGraph = BooleanMapToGraph(boolMap);

            Console.WriteLine("//////////////////////////////////GRAFO ROBOT//////////////////////////////////\n\n");
            Node <MapElement> inicio = robotGraph.NodeList.Find(f => f.Element.Id == 73);

            robotGraph.RUNALL(robotGraph, inicio, 21);


            List <Airport> airports = new List <Airport>();

            foreach (string json in File.ReadAllLines(airportJsonFile))
            {
                airports.Add(JsonConvert.DeserializeObject <Airport>(json));
            }
            bool[,] relations    = GetRelations(airports);
            double?[,] distances = GetDistances(airports, relations);
            ListGraph <Airport> grafo = new MatrixGraph <Airport> {
                EdgesMatrix = distances, NodeDataList = airports
            }.GenerateListGraphFromMatrixGraph();

            Console.WriteLine("\n\n\n\n//////////////////////////////////GRAFO RYANAIR//////////////////////////////////\n\n");
            Node <Airport> inicioRyan = grafo.NodeList.Find(f => f.Element.Id == 73);

            grafo.RUNALL(grafo, inicioRyan, 21);

            Console.ReadLine();
        }
Exemple #2
0
        public static ComplexGraph BuildGraph()
        {
            List <Vertex> vertexes = new List <Vertex>();

            for (int i = 0; i <= 5; i++)
            {
                vertexes.Add(new Vertex()
                {
                    Index = i, Name = $"Vertex {i + 1}"
                });
            }
            ComplexGraph g = new MatrixGraph(vertexes);

            g.AddEdge(0, 1);
            g.AddEdge(0, 5);
            g.AddEdge(1, 2);
            g.AddEdge(1, 4);
            g.AddEdge(2, 3);
            g.AddEdge(2, 5);
            g.AddEdge(3, 4);
            return(g);
        }
Exemple #3
0
        public MatrixGraph <T> GenerateMatrixGraphFromListGraph()
        {
            MatrixGraph <T> matrixGraph = null;

            if (NodeList != null)
            {
                matrixGraph             = new MatrixGraph <T>();
                matrixGraph.EdgesMatrix = new double?[NodeList.Count, NodeList.Count];
                for (int i = 0; i < NodeList.Count; i++)
                {
                    matrixGraph.NodeDataList.Add(NodeList[i].Element);
                    for (int j = 0; j < NodeList.Count; j++)
                    {
                        matrixGraph.EdgesMatrix[i, j] = null;
                    }
                    for (int j = 0; j < NodeList[i].ElementList.Count; j++)
                    {
                        matrixGraph.EdgesMatrix[NodeList[i].ElementList[j].Node.Element.Id, i] = NodeList[i].ElementList[j].Edge;
                    }
                }
            }
            return(matrixGraph);
        }