public void drawPath(GraphState graph, Canvas canvas)
        {
            if (graph.nodes == null || graph.nodes.Count == 0)
                return;

            var affectedNodeIndexes = new List<int>();

            foreach (var edge in graph.edges)
            {
                affectedNodeIndexes.Add(edge.Item1);
                affectedNodeIndexes.Add(edge.Item2);

                if (edgesByIndexPair.ContainsKey(edge))
                    foreach (var line in edgesByIndexPair[edge])
                        line.Stroke = edgePathStroke;
                var reverseEdge = new Tuple<int, int>(edge.Item2, edge.Item1);
                if (edgesByIndexPair.ContainsKey(reverseEdge))
                    foreach (var line in edgesByIndexPair[reverseEdge])
                        line.Stroke = edgePathStroke;
            }

            affectedNodeIndexes = affectedNodeIndexes.Distinct().ToList();
            foreach (int nodeIndex in affectedNodeIndexes)
                nodesByIndex[nodeIndex].Stroke = nodePathIntermediateStroke;

            foreach (var node in graph.nodes)
                nodesByIndex[node.Key].Stroke = nodePathEndStroke;
        }
        public void drawGraph(GraphState graph, Canvas canvas)
        {
            canvas.Children.Clear();
            if (graph.nodes == null || graph.nodes.Count == 0)
                return;

            nodesByIndex = new Dictionary<int, Rectangle>();
            edgesByIndexPair = new Dictionary<Tuple<int, int>, List<Line>>();

            canvas.Height = (nodeHeight + nodeDistance) * graph.nodes.Count + nodeOffsetTop;
            canvas.Height = (canvas.Height > 380) ? canvas.Height : 380;
            canvas.Width = nodeOffsetLeft + nodeWidth + edgeOffsetLeft + edgeDistance * (graph.edges.Count + 1);
            canvas.Width = (canvas.Width > 950) ? canvas.Width : 950;

            int leftEdgeOffset = nodeOffsetLeft + nodeWidth + edgeOffsetLeft;
            Dictionary<int, int> topNodeOffsets = calculateOffsetsForNodes(graph.nodes);

            foreach (var node in graph.nodes)
                drawNode(node.Key, node.Value, canvas, topNodeOffsets);
            foreach (var edge in graph.edges)
                drawEdge(edge.Item1, edge.Item2, canvas, topNodeOffsets, ref leftEdgeOffset);
        }