Exemplo n.º 1
0
 public MainWindowViewModel()
 {
     Problems = new ObservableCollection <ProblemContainer>();
     Graph    = new Graphing.RootCauseGraph();
     app      = (App)Application.Current;
     algs     = app.algs;
 }
Exemplo n.º 2
0
 public void CloseFile()
 {
     SqliteDb.GetInstance().CloseConnection();
     Path       = string.Empty;
     IsFileOpen = false;
     Problems.Clear();
     CurrentProblem = null;
     Graph          = new Graphing.RootCauseGraph();
     NotifyFileChanged();
 }
Exemplo n.º 3
0
        public Graphing.RootCauseGraph GenerateGraph(Node node)
        {
            var newGraph = new Graphing.RootCauseGraph();

            if (node == null)
            {
                return(newGraph);
            }
            var  vertices = new Dictionary <long, Graphing.RootCauseVertex>();
            var  problem  = node;
            bool vertexExists;

            vertices.Add(problem.NodeId, new Graphing.RootCauseVertex(problem));
            newGraph.AddVertex(vertices[problem.NodeId]);

            Func <Node, bool> recurseNodes = null;

            recurseNodes = (Node parent) =>
            {
                foreach (var child in parent.ChildNodes)
                {
                    vertexExists = vertices.ContainsKey(child.NodeId);

                    if (!vertexExists)
                    {
                        vertices.Add(child.NodeId, new Graphing.RootCauseVertex(child));
                        newGraph.AddVertex(vertices[child.NodeId]);
                    }

                    newGraph.AddEdge(new Graphing.RootCauseEdge(vertices[parent.NodeId], vertices[child.NodeId]));
                    if (!vertexExists)
                    {
                        recurseNodes(child);
                    }
                }
                return(true);
            };

            recurseNodes(problem);
            return(newGraph);
        }