Example #1
0
        private void UpdateCurrentContent()
        {
            var nodeSelector = RestrictVisibility
                ? OriginalGraph.GetNodeSelector(SelectedNodeIds, NodeVisitStopFunction, NodeVisitAcceptFunction)
                : null;

            CurrentDotContent = OriginalGraph.ToDot(new DotFormatOptions {
                NodeSelector = nodeSelector
            });
            if (UpdateCurrentImage)
            {
                CurrentImage = GraphParser.GetGraphImage(CurrentDotContent);
            }
            CurrentDotLayoutContent = GraphParser.GetGraphLayoutDot(CurrentDotContent);
            CurrentLayoutGraph      = GraphParser.GetGraph(CurrentDotLayoutContent);

            if (CurrentWpfGraph != null)
            {
                CurrentWpfGraph.Changed -= CurrentWpfGraphChanged;
            }
            CurrentWpfGraph          = new WpfGraph(CurrentLayoutGraph, SelectedNodeIds);
            CurrentWpfGraph.Changed += CurrentWpfGraphChanged;

            if (IsConnectedComponentsEnabled)
            {
                CurrentConnectedComponents = GetConnectedComponents(CurrentLayoutGraph);
            }
        }
Example #2
0
    void Start()
    {
        string fileName = "level";

        GraphParser.OpenFile(fileName);
        Graph graph = GraphParser.GetGraph();

        GraphView.Instance.Draw(graph);

        //Dictionary<Unit, List<Distance>> pathDictionary = graph.GetDistances();
    }
Example #3
0
        public SimpleController()
        {
            if (Environment.GetCommandLineArgs().Length <= 1)
            {
                throw new ArgumentException("No filename argument given!");
            }
            var filename   = Environment.GetCommandLineArgs()[1];
            var dotContent = File.ReadAllText(filename);

            try {
                GraphParser.CheckSyntax(dotContent);
            } catch (Exception e) {
                throw new ArgumentException("Invalid graph syntax:" + Environment.NewLine + e.Message);
            }
            var graph       = GraphParser.GetGraph(dotContent);
            var layoutGraph = GraphParser.GetGraphLayout(graph.ToDot());

            Graph = new WpfGraph(layoutGraph);
        }
Example #4
0
 private void UpdateOriginalGraphFromDotContent()
 {
     try {
         var graph = GraphParser.GetGraph(OriginalDotContent);
         GraphParser.CheckSyntax(OriginalDotContent);
         OriginalGraph       = graph;
         ParseFailureMessage = "";
     } catch (Exception e) {
         ParseFailureMessage = e.Message;
     }
     if (OriginalGraph == null)
     {
         OriginalGraph = Graph.CreateGraph();
     }
     if (string.IsNullOrEmpty(ParseFailureMessage))
     {
         RestrictSelection();
         RaiseContentChanged();
     }
 }
Example #5
0
        private static void Main(string[] args)
        {
            var file = args.Length > 0 ? new FileInfo(args[0]) : new FileInfo(DefaultInputFile);

            if (!file.Exists)
            {
                throw new FileNotFoundException(FormattableString.Invariant($"File {file.FullName} not found!"));
            }

            var graph    = GraphParser.GetGraph(file);
            var graphDot = graph.ToDot();

            Console.Write(graphDot);
            Console.WriteLine("Press any key...");
            Console.ReadKey();

            try {
                var originalDot = file.OpenText().ReadToEnd();
                var initialDot  = GraphParser.GetGraphLayoutDot(originalDot);
                var reparsedDot = GraphParser.GetGraphLayoutDot(graphDot);
                var diff        = DiffHelper.GetDiff(initialDot, reparsedDot);
                //var initialReparsed = GraphParser.GraphParser.GetGraph(initialDot).ToDot();
                //var reparsedReparsed = GraphParser.GraphParser.GetGraph(reparsedDot).ToDot();
                //var diff = DiffHelper.GetDiff(initialReparsed, reparsedReparsed);
                Console.Clear();
                Console.Write(diff);
                Console.WriteLine("Press any key to generate outOriginal.png, out.png and layout.gv...");
                Console.ReadKey();

                GenerateOutput(originalDot, graphDot, reparsedDot);

                Console.Clear();
                Console.WriteLine("Press any key...");
                Console.ReadKey();
            } catch (Exception e) {
                Console.Clear();
                Console.Write(e.Message);
                Console.WriteLine("Press any key...");
                Console.ReadKey();
            }
        }