Example #1
0
        /// <summary>
        /// Retourne un object CustomGraph qui pourra être utilisé pour générer la visualisation
        /// Crée l'object à partir d'une chaine de caractères JSON
        /// </summary>
        /// <param name="json_string">Chaine de caractères JSON</param>
        /// <returns>CustomGraph</returns>
        public static CustomGraph loadGraphFromJson(string json_string)
        {
            CustomGraph graph = new CustomGraph();

            // On converti la string JSON en object JsonGraph
            JsonGraph jsonGraph = JsonConvert.DeserializeObject <JsonGraph>(json_string);

            // On ajoute tous les arcs
            foreach (JsonEdge edge in jsonGraph.ExecutionNodes)
            {
                graph.addEdge(edge.Source, edge.Dest, edge.Time, edge.Name);
            }

            // On ajoute les informations comprises dans "node_selection"
            foreach (JsonNode node in jsonGraph.NodeSelection)
            {
                CustomNode graph_node = graph.nodes[node.Id];

                graph_node.visited          = true;
                graph_node.heuristic_value  = node.HeuristicValue;
                graph_node.real_final_value = node.RealFinalValue;
                graph_node.order_visited    = node.Order;
            }

            // On ajoute les informations comprises dans "selected_path"
            foreach (JsonNode node in jsonGraph.SelectedPath)
            {
                CustomNode graph_node = graph.nodes[node.Id];

                graph_node.in_selected_path = true;
            }

            return(graph);
        }