Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using edges (WPF) #68

Open
Skyppid opened this issue Nov 8, 2016 · 1 comment
Open

Issue when using edges (WPF) #68

Skyppid opened this issue Nov 8, 2016 · 1 comment

Comments

@Skyppid
Copy link

Skyppid commented Nov 8, 2016

I get the following exception:
"Specified argument was out of the range of valid values. Parameter name: index"

> MS.Utility.FrugalStructList`1.get_Item(Int32 index)
> GraphX.Controls.EdgeControlBase.PrepareEdgePath(Boolean useCurrentCoords, Point[] externalRoutingPoints, Boolean updateLabel)
> GraphX.Controls.EdgeControlBase.UpdateEdgeRendering(Boolean updateLabel)
> GraphX.Controls.EdgeControlBase.UpdateEdge(Boolean updateLabel)
> System.Windows.FrameworkElement.ApplyTemplate()
> System.Windows.FrameworkElement.MeasureCore(Size availableSize)
> System.Windows.UIElement.Measure(Size availableSize)
> GraphX.GraphAreaBase.MeasureOverride(Size constraint)
> System.Windows.FrameworkElement.MeasureCore(Size availableSize)
> System.Windows.UIElement.Measure(Size availableSize)
> System.Windows.ContextLayoutManager.UpdateLayout()
> System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
> System.Windows.Interop.HwndSource.LayoutFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
> MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
> MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
> System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
> System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
> System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
> MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
> MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
> MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
> MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
> MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

When I generate the graph with edges. When I don't, it works. Since I render a binary tree of my Heap Sort algorithm it seems like it only happens with a certain set of vertices and edges. This is my generating code:

        private BinaryGraph BuildGraph(int[] data)
        {
            BinaryGraph graph = new BinaryGraph();

            foreach (int t in data)
                graph.AddVertex(new GraphVertex(t));

            GraphVertex[] vertices = graph.Vertices.ToArray();
            for (int i = 0; i < data.Length; i++)
            {
                int left = 2*i + 1;
                int right = 2*i + 2;

                if (left < vertices.Length)
                    graph.AddEdge(new GraphEdge(vertices[i], vertices[left]));
                if (right < vertices.Length)
                    graph.AddEdge(new GraphEdge(vertices[i], vertices[right]));
            }

            return graph;
        }

Everything else has been copied over from the sample application and works obviously.

@Skyppid
Copy link
Author

Skyppid commented Nov 8, 2016

Notice: I changed the LogicCore setup a little bit.

            LogicCore logicCore = new LogicCore
            {
                Graph = BuildGraph(data),
                DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.Tree
            };

            SimpleTreeLayoutParameters param;
            logicCore.DefaultLayoutAlgorithmParams = param = (SimpleTreeLayoutParameters)logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.Tree);
            //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm.
            param.Direction = LayoutDirection.TopToBottom;

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;
            //Default parameters are created automaticaly when new default algorithm is set and previous params were NULL
            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap = 50;

            //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
            //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
            //Bundling algorithm will try to tie different edges that follows same direction to a single channel making complex graphs more appealing.
            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;

            //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
            //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
            //Area.RelayoutFinished and Area.GenerateGraphFinished.
            logicCore.AsyncAlgorithmCompute = false;

            //Finally assign logic core to GraphArea object
            Area.LogicCore = logicCore;

The issue could be resolved by switching back to "SimpleER" instead of "Pathfinder" as I initially used it. You might want to investigate into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant