Giter Club home page Giter Club logo

automatic-graph-layout's Introduction

Microsoft Automatic Graph Layout

MSAGL is a .NET library and tool for graph layout and viewing.

MSAGL was developed in Microsoft by Lev Nachmanson, Sergey Pupyrev, Tim Dwyer, Ted Hart, and Roman Prutkin.

Getting Started

The simplest way to start with MSAGL in C# is to open GraphLayout.sln in Visual Studio and browse the Samples folder.

Note: This repository requires Visual Studio with the UWP (Universal Windows Platform) development workload installed, as well as the Windows 10 SDK. If these are not installed, Visual Studio will recommend installing them when you open the solution. Please ensure these components are installed to successfully build the project.

MSAGL Modules

The Core Layout engine (AutomaticGraphLayout.dll) - NuGet package This .NET asssembly contains the core layout functionality. Use this library if you just want MSAGL to perform the layout only and afterwards you will use a separate tool to perform the rendering and visalization.

The Drawing module (AutomaticGraphLayout.Drawing.dll) - NuGet package The Definitions of different drawing attributes like colors, line styles, etc. It also contains definitions of a node class, an edge class, and a graph class. By using these classes a user can create a graph object and use it later for layout, and rendering.

A WPF control (Microsoft.Msagl.WpfGraphControl.dll) - NuGet package The viewer control lets you visualize graphs and has and some other rendering functionality. Key features: (1) Pan and Zoom (2) Navigate Forward and Backward (3) tooltips and highlighting on graph entities (4) Search for and focus on graph entities.

A Windows Forms Viewer control (Microsoft.Msagl.GraphViewerGdi.dll) - NuGet package The viewer control lets you visualize graphs and has and some other rendering functionality. Key features: (1) Pan and Zoom (2) Navigate Forward and Backward (3) tooltips and highlighting on graph entities (4) Search for and focus on graph entities.

Code Samples

The code snippets demonstrate the basic usage of the viewer. It uses the C# language.

The Viewer sample

Drawing of the graph from the sampleDrawing of the graph from the sample

Drawing of the graph from the sampleDrawing of the graph from the sample

using System;
using System.Collections.Generic; 
using System.Windows.Forms; 
class ViewerSample { 
    public static void Main() { 
    //create a form 
        System.Windows.Forms.Form form = new System.Windows.Forms.Form();
    //create a viewer object 
        Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
    //create a graph object 
        Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
    //create the graph content 
        graph.AddEdge("A", "B");
        graph.AddEdge("B", "C");
        graph.AddEdge("A", "C").Attr.Color = Microsoft.Msagl.Drawing.Color.Green;
        graph.FindNode("A").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta;
        graph.FindNode("B").Attr.FillColor = Microsoft.Msagl.Drawing.Color.MistyRose;
        Microsoft.Msagl.Drawing.Node c = graph.FindNode("C");
        c.Attr.FillColor = Microsoft.Msagl.Drawing.Color.PaleGreen;
        c.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Diamond;
    //bind the graph to the viewer 
        viewer.Graph = graph;
    //associate the viewer with the form 
        form.SuspendLayout();
        viewer.Dock = System.Windows.Forms.DockStyle.Fill;
        form.Controls.Add(viewer);
        form.ResumeLayout();
    //show the form 
        form.ShowDialog();
    } 
}

More code samples can be found here…

GraphMaps

GraphMaps lets you view very large graphs like oneline maps - as you zoom in more detail is revealed. Watch a video that shows how GraphMaps works, and here is the video of the previous version.

Using GraphMaps

  • open GraphLayout.sln and build the solution,
  • run TestGraphMaps.

NOTES:

  • The configuration Release/x64 needs to be used to load a large graph.
  • The graph from the video can be found in GraphLayout/graphs/composers.zip. Please load composers.msagl to avoid the preprocessing step.
  • If composers.dot is loaded then composers.msagl and the tiles directory composers.msagl_tiles will be regenerated.

Learn More

The ideas, design, and the mathematics of GraphMaps are described in this paper.

Layouts Created by MSAGL

MSAGL in JavaScript

WebMSAGL is a version of MSAGL that was transcompiled to JavaScript with SharpKit, plus a TypeScript wrapper and rendering/interaction layer that provides a friendly TypeScript API. You can create a graph either programmatically or from a JSON object, have MSAGL create a layout for it, and then render it to an HTML Canvas or to an SVG block. All layout operations are run in a web worker, ensuring that your application remains responsive while computation is taking place. Limited interactivity is also supported.

Using WebMSAGL

  • open WebMsagl.sln and build the solution,
  • set index.html from any of the sample folders as the starting page,
  • run WebMsagl.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Build

Build Status

Producing a release

A release containing the binaries of agl.exe can be created automatically by a github action of ".github\workflows\agl.yaml'. To invoke the action do the following. Create a new tag in the form "v*". For example, "git tag -a v_11 -m "some comment here"". Then execute git push with this tag: "git push origin v_11". These should trigger the release creation. Alternatively, you can use python script "createRelease.py", as following "python createRelease.py 1.1.1".

automatic-graph-layout's People

Contributors

aplacuzzi avatar austin-lamb avatar baudin999 avatar beru avatar brains avatar cgravill avatar daveaglick avatar dependabot[bot] avatar derjabkin avatar filippopolo avatar filiprychnavsky avatar foreverstupid avatar hydrahorizon avatar i-to avatar jobubo avatar juhan avatar levnach avatar microsoft-github-policy-service[bot] avatar mkosieradzki avatar mo avatar nicholasudell avatar nikolajbjorner avatar paulovila avatar rafntor avatar rassilon avatar speedwago avatar stefanloerwald avatar steventcramer avatar twsouthwick avatar zebmason avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

automatic-graph-layout's Issues

Silverlight build fails

CSC : error CS2001: Source file '..\msagl\Layout\LargeGraphLayout\ShortestPathToAllOthers.cs' could not be found

Forgot to add a file?

Fyi,
Bill

Null ref exception at GraphControlTest.MainPage in GraphControlSilverlight\GraphControlTest

at GraphControlTest of GraphContorlSilverlight.sln, at MainPage.xaml.cs, the following code

   private void LayoutGeometry_Click(object sender, RoutedEventArgs e)
    {
        var dgraph = FromGeometryContainer.Children[0] as DGraph;
        var dg = dgraph.Graph;
        GeometryTest.Layout(dg.GeometryGraph);
        dgraph.Invalidate();
    }

results in null ref exeption at "var dg = dgraph.Graph" because the "Children[0]" of the container is returning a Button, not a DGraph, so the "as DGraph" gives null

this error occurs at last page of that SL demo, by pressing Layout button at that tab (I see nothing in the graph display btw in that page)

have also tried first pressing the "Geometry Test" button which may be unrelated to that page though since it always appears at top-right, not only when you have that last tab page selected (not sure what that button does either)

Absolute positioning of nodes with overlap removal

Hey everyone,

first of all I want to thank you all for this great tool. I have taken a look at the automatic-graph-layout and I am wondering if the following is possible:
Using the GraphViewer for WPF: Can I place nodes at given coordinates right at the beginning, such that one of the given layouts would move them relatively to avoid any overlaps?

The FastIncrementalLayout seems quite promissing with the use of the LockPosition class. But I have not managed to place my nodes correctly at first place (esp. without grouping nodes corresponding to connected components). It appears to me that the given locks are ignored in the initial layout.

Best
Markus

Nodes with the same name

Hello,

first very thanks for this .NET component. Incredibly usefull !!!

I have a question - i need to create two nodes with the same name in the same graph but it doesn't seem to be possible with the method - AddEdge(string, string)

Is there another solution for that ?

Thank you :)

Fix creating SugiyamaLayoutLogger

In one of the constructors in LayeredLayoutEngine.cs there is missing auto-creation of logger (when Reporting enabled). It could lead to null reference exception when Reporting enabled.

So I added it by analogy with other version of constructor.

There's also 3rd version of constructor I didn't touch.

1.diff.txt

Move graph programmatically

I would like to move my graph programmatically (for example with scrollbars) or even to center the position of a selected node. It seems that there is a gViewer.Transform method which could do this, but I cannot figure out how to use it or even if there is a better approach.

Thanks for your suggestion!

Coordinates of all nodes from a default location of a node

I'm able to get the coordinates of the nodes with GeometryGraph, but they are -ve for X and large +ve for Y. For example, I see (x, y) = (-630, 700) which can't be plotted on the browser. I can do the adjustment, but then I have to apply the same to the edges also.

Can I specify the default location of a node and the coordinates of the other nodes and edges can be calculated based on that?

What is the purpose of these properties

Hi, there are some LayoutAlgorithm properties, for which I can not figure out from the examples what they do:
MDS:

  • Number of pivots
  • CallIterationsWithMajorizationThreshold
  • ClusterMargin
  • Exponent
  • NumberofInterationswithMajorization

Sugiyama

  • Fast X-coordinate assignment algorithm threshold
    (actually: how can I set this via a LayoutAlgorithmSettings object, I can only find it in the LeyoutSettings-Dialog in the viewer)
  • Group Split

Edge Routing Settings:

  • IncrementalRoutingThreshold
  • KeepOringinalSpline
  • UseObstacleRectangles

Microsoft.Msagl.GraphViewerGdi.GViewer.CreateEdgeWithGivenGeometry() is losing Label

Microsoft.Msagl.GraphViewerGdi.GViewer.CreateEdgeWithGivenGeometry(DrawingEdge drawingEdge) { drawingEdge.Label = new Label(); (...)

This makes us lose the Label.Text passed. I've corrected it:

    public IViewerEdge CreateEdgeWithGivenGeometry(DrawingEdge drawingEdge)
    {
        //ADAC: protect parameter Label 
        if (drawingEdge.Label == null)
            drawingEdge.Label = new Label();
        Edge geometryEdge = drawingEdge.GeometryEdge;
        Debug.Assert(geometryEdge != null);
        geometryEdge.GeometryParent = Graph.GeometryGraph;

        var dEdge = new DEdge(DGraph.FindDNode(drawingEdge.SourceNode.Id), DGraph.FindDNode(drawingEdge.TargetNode.Id),
                              drawingEdge, ConnectionToGraph.Disconnected, this);
        //ADAC: use parameter Label
        //dEdge.Label = new DLabel(dEdge, new Label(), this);
        dEdge.Label = new DLabel(dEdge, drawingEdge.Label, this);
        return dEdge;
    }

but when using:

                    Microsoft.Msagl.Drawing.Edge dEdge = this.fGViewer.AddEdge(nodeFound.Node, node1, false);
                    dEdge.LabelText = ete.LabelText;
                    dEdge.Attr.Color = ete.Color;
                    dEdge.UserData = ete.UserData;
                    //(...)
                    if (OnEdgeAdding != null)
                        OnEdgeAdding(dEdge);

                    fGViewer.CreateEdgeWithGivenGeometry(dEdge);
                    fGViewer.SetEdgeLabel(dEdge, dEdge.Label);

The edge is created but the label is still not present.
Well, I'll have to really study the code to be able to use it. Its object hierarchy is not easy...

automatic-graph-layout core Failure

Hi,

Testing my program, something strange has happened.
With the FormPrincipal program alive (without closing it)
I dispose the form that contains references to a gviewer and graph. (I call FormGraph.dispose() method)

my next operation is reload the same form that contains a graph, with diferent content (diferent number of nodes, but is the same form)
I do a new instance of the form.

It crassesh here in DrawingPanel.cs [automatic-graph-layout core class] :

void ProcessPan(MouseEventArgs args) {
if (ClientRectangle.Contains(args.X, args.Y)) {
if (args.Button == MouseButtons.Left) {
gViewer.Transform[0, 2] = mouseDownTransform[0, 2] + args.X - mouseDownPoint.X;
gViewer.Transform[1, 2] = mouseDownTransform[1, 2] + args.Y - mouseDownPoint.Y;
gViewer.Invalidate();
} else
GViewer.Hit(args);
}
}

telling that mouseDownTransform is null.

Why could it be?

here is the stacktrace

************** Texto de la excepción **************
System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.
en Microsoft.Msagl.GraphViewerGdi.DrawingPanel.ProcessPan(MouseEventArgs args) en C:\Aitor\SVN\graph-layout\automatic-graph-layout.git\trunk\GraphLayout\tools\GraphViewerGDI\DrawingPanel.cs:línea 261
en Microsoft.Msagl.GraphViewerGdi.DrawingPanel.OnMouseMove(MouseEventArgs args) en C:\Aitor\SVN\graph-layout\automatic-graph-layout.git\trunk\GraphLayout\tools\GraphViewerGDI\DrawingPanel.cs:línea 210
en System.Windows.Forms.Control.WmMouseMove(Message& m)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Aspect Ratio not being used

In the AspectRatioSample, changing the aspect ratio, simple stretch setting, and min width/height doesn't seem to have any effect on the graph. No combinations of values that I have tried result in the graph layout changing from the original layout.

image

SameLayerSample not working

I know that it has worked sometime back, but the sample SameLayerSample that shows nodes in the same layer is not working.

This is what I see now. I use the latest sources from GitHub.

layer

AutoScroll is not working

The AutoScroll property is not working in WinForms, I have not tried in WPF yet,
I have forced with gViewer1.AutoScroll = true; but it's still not working.

The property itself is working well in many earlier versions of MSAGL, and the outdated GLEE.
With the current version, it is not working anymore.

GraphMaps cause AV with Triangle.c line 5795

I can render graph's just fine with the same input, 32 & 64 bit builds.

Details from output window on debug builds;

starting processing a graph with 613 nodes and 613 edges
LayoutConnectedGraphWithMds: nodes 7 edges 7
LayoutConnectedGraphWithMds: nodes 7 edges 7
LayoutConnectedGraphWithMds: nodes 85 edges 85
LayoutConnectedGraphWithMds: nodes 166 edges 166
LayoutConnectedGraphWithMds: nodes 281 edges 281
LayoutConnectedGraphWithMds: nodes 53 edges 53
LayoutConnectedGraphWithMds: nodes 14 edges 14
done with LayoutConnectedComponents
done with LayoutConnectedComponents
done with LayoutConnectedComponents
done with LayoutConnectedComponents
done with LayoutConnectedComponents

done with LayoutConnectedComponents

done with LayoutConnectedComponents

zoom level = 1 with the grid size = 18912.8093279865
zoom level = 2 with the grid size = 9456.40466399327
zoom level = 4 with the grid size = 4728.20233199663
zoom level = 8 with the grid size = 2364.10116599832
zoom level = 16 with the grid size = 1182.05058299916
zoom level = 32 with the grid size = 591.025291499579

Removing overlaps
..
Initializing Cdt input

Writing Cdt input

Call Site

00 triangle!incircleadapt(void)+0x6fa3 [c:\users\files\downloads\triangle\triangle.c @ 5795]
01 triangle!counterclockwiseadapt(void)+0xbcf [c:\users\files\downloads\triangle\triangle.c @ 5217]
02 triangle!orient3dadapt(void)+0x726c [c:\users\files\downloads\triangle\triangle.c @ 6319]
03 KERNEL32!BaseThreadInitThunk+0x22
04 ntdll!RtlUserThreadStart+0x34

The below fragment is where windbg pop's up...

      negate = -ady;
      Two_Product(bdxtail, negate, ti1, ti0);
      negate = -adytail;
      Two_Product(bdx, negate, tj1, tj0);
      Two_Two_Sum(ti1, ti0, tj1, tj0, v3, v[2], v[1], v[0]); // <== Crash is here
      v[3] = v3;
      abtlen = fast_expansion_sum_zeroelim(4, u, 4, v, abt);

      Two_Product(adxtail, bdytail, ti1, ti0);
      Two_Product(bdxtail, adytail, tj1, tj0);

Attached is the file which causes the crash, thanks.

pointssegments8720.poly.txt

Controlling node size

Hi,
This code is having no effect on my node sizes. The ellipse shape setting succeeds but not the radius settings. Am I doing something wrong? [F#, but the core thing is setting the n.Attr.XRadius/YRadius]:

vertices 
    |> Seq.map (fun (v,c)-> (v,c,graph.FindNode(v)))
    |> Seq.filter (fun (v,c,n)->n<>null)
    |> Seq.iter (fun (v,c,n) -> 
                   let r= 100.+(log10 (float c))/(log10 (float vMax))*400.                 
                   n.Attr.Shape<-Microsoft.Msagl.Drawing.Shape.Ellipse
                   n.Attr.XRadius<-r
                   n.Attr.YRadius<-0.5*r)

Microsoft.Msagl.GraphViewerGdi.GViewer.AddEdge commented

In Microsoft.Msagl.GraphViewerGdi.GViewer there was an AddEdge method :

public Microsoft.Msagl.Drawing.Edge AddEdge(Microsoft.Msagl.Drawing.Node source, Microsoft.Msagl.Drawing.Node target, bool registerForUndo)  

That method is now commented.
I do use MSAGL, in a former version, in a simple application where I want to add edges by selecting two nodes and invoke a contextual menu to select an edge type. I just need a straight edge between the two nodes.
It seems that the new version is only allowing to draw edges by dragging. I really think this is not the best approach as it steals a lot of flexibility from the tool. One of its strengths is to allow usage in whatever interaction model the programmer wants.
Can somebody help? Maybe I'm not seeing it right. I'm just beginning to explore version 3 (but upgrade is being painful...).
Best regards
André de Carvalho

Change background image of gviewer doesn't work

Hi,

trying with FindEmptySpotSample project in samples

I have put the gViewer back color to "Maroon"
in preview looks great:

captura

But when I execute the program always looks Gray background color.

captura2

How could I change that property

MouseWheelZoom and Cursor

Hello all,

The more time i spend using this librairy, the more i love it :) and the more i have questions :/

The first one is : When the "PanButtonPressed" is set to True, the cursor looks like a hand. Is it possible to set it back to default cursor ?

The second one is about the Zoom on MouseWheel. In my application, it works only if i click first in the background of my graph. And if i click on a node or arrow, it doesnt work anymore - i need to click again in the background. Is it normal ? and is it possible to activate it all the time ?

thank you for your help

Shape.DoubleCircle behaviour

Hi.
I'm trying to create 2 nodes, one shaped circle, one shaped double circle. The circle node is... a circle, and fits perfectly with the label. But the double circle one is somewhat like an ellipse, and it is much bigger that the circle node. Is this behaviour intended? And is there anyway to change the size of those nodes? Thank you.

sugiyamaSettings and Rectilinear EdgeRoutingMode problem

Hi Lev,
Im trying to use "Rectilinear EdgeRoutingMode" in my project.

In the Editing sample I have modified the form1 creation adding sugiyamaSettings to set rectilinear edgeroutingmode:

    public Form1() {

        graphEditor = new GraphEditor();
        InitializeComponent();
        graphEditor.AddNodeType("Ellipse", Shape.Ellipse, Color.Transparent, Color.Black, 10, "user data",
                                "New Node");
        graphEditor.AddNodeType("Square", Shape.Box, Color.Transparent, Color.Black, 6, "user data", "");
        graphEditor.AddNodeType("Double Circle", Shape.DoubleCircle, Color.Transparent, Color.Black, 6, "user data",
                                "New Node");
        graphEditor.AddNodeType("Diamond", Shape.Diamond, Color.Transparent, Color.Black, 6, "user data", "New Node");
        graphEditor.Viewer.NeedToCalculateLayout = true;
        CreateGraph();

        //Added piece of code
        var sugiyamaSettings = (SugiyamaLayoutSettings)graphEditor.Viewer.Graph.LayoutAlgorithmSettings;
        sugiyamaSettings.EdgeRoutingSettings.EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.Rectilinear;
        //End added  piece of code

        graphEditor.Viewer.NeedToCalculateLayout = false;

        SuspendLayout();
        helpButton.BringToFront();
        graphEditor.Viewer.LayoutAlgorithmSettingsButtonVisible = false;


        ResumeLayout();
        helpButton.Click += helpButton_Click;

    }   

When I execute the application appears like this. It doesn't take the SugiyamaLayoutSettings that I set.
captura1

If I drag one item the graph appearance changes ands shows me the correct rectilinear edges.
captura3

After that if I push right button and select the option "redo Layout" y recovers the firs image aspect.

The question is: what do I have to do to take my SugiyamaLayoutSettings in the graph in the first draw?

Thanks for your time!

Panning problem (Samples\WpfApplicationSample)

Sometimes when I start dragging outside of graph it either won't move or move to unexpected position.
It's fine if I start dragging inside of graph or re-size window first or zoom-in/zoom-out first.

merge drawing nodes with normal ones.

Hi,
congrats for msagl, It looks nice.
I'm developing a graph using msagl library in c#.

I have the next problem: I am not able to merge nodes with images (Shape.DrawFromGeometry) with normal shapes nodes ().
when I do it the normal ones disappear from the graph.
I have just modify the sample "NodesWithImages.csproj" to get the most easy example.

private void InitGraph() {
Graph drawingGraph = new Graph();

        drawingGraph.AddEdge(leavesId, creekId);
        drawingGraph.AddEdge(leavesId, treeId);
        drawingGraph.AddEdge(leavesId, wId);
        drawingGraph.AddEdge("uno","otro");
        foreach (DrawingNode node in drawingGraph.Nodes) {
            if (!node.Id.Equals("uno"))
            {
                node.Attr.Shape = Shape.DrawFromGeometry;
                node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(DrawNode);
                node.NodeBoundaryDelegate = new DelegateToSetNodeBoundary(GetNodeBoundary);
            }
            else
            {
                node.LabelText = "bla";
                node.Attr.Shape = Shape.Diamond; 
                node.DrawNodeDelegate = null;
                node.NodeBoundaryDelegate = null;

            }

        }

        double width = leaves.Width;
        double height = leaves.Height;

        drawingGraph.Attr.LayerSeparation = height / 2;
        drawingGraph.Attr.NodeSeparation = width / 2;
        double arrowHeadLenght = width / 10;
        foreach (Microsoft.Msagl.Drawing.Edge e in drawingGraph.Edges)
            e.Attr.ArrowheadLength = (float)arrowHeadLenght;
        drawingGraph.LayoutAlgorithmSettings = new SugiyamaLayoutSettings();
        viewer.Graph = drawingGraph;
    }

So the node called "uno" should appear as a diamond node. But it doesn't get draw.
When I debug the code I looks right, like diamond node until the end of debug. At the end it presents me like this:
captura

thanks!!!!

Rectangular EdgeRouting: Edges through nodes

Dear developers of the automatic-graph-layout,

I noticed a strange behavior using the EdgeRoutingMode Rectilinear (a description how I construct the graph/viewer is given below the video).
I am working on a bigger project, where the following happens (see video):
When I am dragging a node from the left or the right crossing vertical parts of edges does not move them and edges of the node might cross other nodes. This does not happen with vertical movements.
This only happens for a few nodes inside slightly bigger graphs (> 20 nodes).

2016-04-04 17h18_31

I am going through the following steps:
*) Construct a GraphViewer (WpfGraphControl) and bind it to a panel
*) Construct a Graph "Pregraph":
PreGraph = new Graph(); PreGraph.LayoutAlgorithmSettings = new FastIncrementalLayoutSettings(); this.NeedToRemoveOverlapOnly = true; PreGraph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.Rectilinear;
*) Avoid layout by the viewer: this.NeedToCalculateLayout = false;

-- After the window containing the panel for the viewer is loaded:

*) Generate a set of nodes, add them to the "PreGraph" and register the LabelCreators
*) Add the edges to the "PreGraph"
*) Create the geometryGraph: PreGraph.CreateGeometryGraph();
*) For the viewer set: NeedToCalculateLayout = false; NeedToRemoveOverlapOnly = true;
*) For each edge update the BoundaryCurve (using CurveFactory methods)
*) viewer.Graph = PreGraph
*) An iteration over all nodes modifying their positions
*) Call Microsoft.Msagl.Core.Layout.ProximityOverlapRemoval .MinimumSpanningTree.OverlapRemoval .RemoveOverlaps(nodes, 50);
*) Call LayoutHelpers.RouteAndLabelEdges(m_GraphViewer.PreGraph.GeometryGraph, m_GraphViewer.PreGraph.LayoutAlgorithmSettings, GraphViewer.PreGraph.GeometryGraph.Edges); foreach (var item in m_GraphViewer.Entities) { m_GraphViewer.Invalidate(item); }

Loading a saved msagl graph fails when an edge includes a cubicBezierSegment

The following edge causes an XML deserialization error, seemingly because the reader is not handling an empty element properly for this element type:

<edge id="43" s="1004" t="3820" at="820.27115504438 1280.10511746146" label="839.4898474743 1255.50621108601 8.89843654633 18.10937309265">
>         <cubicBezierSegment points="836 1231.64059638977 836 1244.92627412229 832.45381829596 1258.21195185481 825.36145488788 1271.49762958733" />
</edge>

Error message box: " 'Element' is an invalid XML XmlNodeType. Line 9210, position 10"

RankingLayout example

I'm trying to generate a directed graph, but with constraints like some nodes should be on the same layer or rank. For example, I have four nodes A, B, C, D. The relationships is

A => B
A => C
A => D

When the graph is drawn I want the nodes A, B, C are on the same layer and the D in the second layer. I don't see any property on Node through which I can set the rank. How can I achieve this with RankingLayout?

Other Test Failures

These other unit tests also failed for as yet, un-analyzed reasons:

PolygonPolygonDistanceTest1
PolygonPolygonDistanceTest3
RTreeQuery_IncrementalRectangles
RTreeQuery_Rectangles
WideRatioSimpleSearch

Fyi,
Bill

msaglsilverlight doesn't contain subfolders

Seems somebody has linked files from various folders flat inside msaglsilverlight

Since there are two LayerInfo.cs files, one at \msagl\Layout\LargetLayout\ and one at \msagl\Layout\Layered\Ordering\ this causes the following warning:

Warning 1 The file '..\msagl\Layout\Layered\Ordering\LayerInfo.cs' could not be added to the project. Cannot add a link to the file LayerInfo.cs. There is already a file of the same name in this folder. msaglsilverlight

Instead project subfolders should be added and then the linked files dragged into them. Only side-effect of this is that it creates respective empty folders (if they only contain links) under that Silverlight project, but this should resolve the issue I see above, since I see those two LayerInfo.cs files are different (have different namespace). Now only one of them is compiled in the library and can be used from other projects that refer to this library

WPF GraphViewer throws exception if Graph.Attr.LayoutDirection is set

I have a simple WPF application which displays a 2-node graph with an edge between the two nodes. If I set the Attrs.LayoutDirection for the graph to LayoutDirection.LR, the GraphViewer throws a NullReferenceException upon setting the graph. The null reference is the Node.BoundaryCurve member in the method call Node.Transform(PlaneTransformation).

See code below:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        Loaded += MainWindow_Loaded;
    }

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        GraphViewer graphViewer = new GraphViewer();
        graphViewer.BindToPanel(Panel);
        Graph graph = new Graph();

        graph.AddEdge("A", "B");
        graph.Attr.LayerDirection = LayerDirection.LR;
        graphViewer.Graph = graph; // throws exception
    }
}

SvgGraphWriter problem

This class does not write nodes which are subgraphs. I was trying to introduce this function with code:

WriteSubGraphs();  //new method
WriteEdges();
WriteNodes();

...................................
void WriteSubGraphs()
{
   WriteComment("subgraphs");
   foreach (Subgraph ab in _graph.RootSubgraph.Subgraphs) WriteSubGraph(ab);
   WriteComment("end of subgraphs");
}

void WriteSubGraph(Subgraph subgraph)
{
   WriteNode(subgraph);
   foreach (Subgraph sg in subgraph.Subgraphs) WriteSubGraph(sg);
}

The problem is that all subgraphs in the svg file are not correectly vertical aligned, they are too much bottomed

Publish nuget package

First of all thanks for open sourcing MSAGL and removing of "Windows-only" restriction from the license!

It would be great to have NuGet package in official repository or in a nightly feed.

Reset graph position in the viewer

Hello,

After using the zoom feature, it is possible to reset the zoom size using the zoomfactor attribute and set to 1 :)

That is said, when i move my graph in the viewer using PanButtonPressed attribute, how can i reset my graph to its original position in the viewer ?

thank you

deselect an edge in GViewer

Hypernut asks" Can I programmatically deselect an edge, which has been selected by mouse-click?
I tried setting SelectedForEditing = $false and MarkedForDragging = $false, but without success."

Move a node

Hello

i wanna move nodes in my graph with my mouse click. How can i activate that with code ?

By default, it seems to be desactivated.

ty

Compilation failed under MS VS 2013

It's said in the project's readme.md:

The simplest way to start with MSAGL in C# is to open GraphLayout.sln in Visual Studio 2013, and have a look at Samples there.

But, when there are several c# 6.0 syntax lines that rise errors

  • Error 1 Invalid expression term '.' GraphViewerGDI\GViewer.cs 1752
  • Error 34 Invalid expression term '.' GraphViewerGDI\GViewer.cs 1276
  • Error 35 Syntax error, ':' expected GraphViewerGDI\GViewer.cs 1276

It's not big deal but, is there a reason for c# 6.0 usage only for
selectedDObject = geometry?.dObject;
instead of
return g==null?null:g.dObject;at line GViewer.cs 1752
?

CancelException vs OperationCanceledException

at LayoutHelpers.cs I see:

#if SILVERLIGHT
        /// <summary>
        /// Calculates the graph layout
        /// </summary>
        /// <exception cref="CancelException">Thrown when the layout is canceled.</exception>
#else
        /// <summary>
        /// Calculates the graph layout
        /// </summary>
        /// <exception cref="System.OperationCanceledException">Thrown when the layout is canceled.</exception>
#endif
        public static void CalculateLayout...

but this causes warning:

Warning 5   XML comment on 'Microsoft.Msagl.Miscellaneous.LayoutHelpers.CalculateLayout(Microsoft.Msagl.Core.Layout.GeometryGraph, Microsoft.Msagl.Core.Layout.LayoutAlgorithmSettings, Microsoft.Msagl.Core.CancelToken)' has cref attribute 'CancelException' that could not be resolved  .....\automatic-graph-layout\GraphLayout\msagl\Miscellaneous\LayoutHelpers.cs   34  30  msaglsilverlight

I don't understand why a conditional is used there for Silverlight, since
https://msdn.microsoft.com/en-us/library/system.operationcanceledexception(v=vs.95).aspx
says there is an OperationCanceledException for Silverlight 5 (maybe that is older code that wanted to support Silveright 4? I don't see any need to still support SL4, esp. since MoonLight is now totally obsolete and PipeLight has been released [http://pipelight.net/cms/about.html] for Linux)

Probably needs changes to other places CancelException is used in the code to use OperationCanceledException instead.

Anyway even if SL5 hadn't added that class, one could have added such class and if somewhere CancelException was thrown by internal system code, could catch it and rethrow it again as OperationCanceledException to keep the code cleaner

Expand/Collapse subgraph in Windows Form

I have noticed that this functionality is only available for Wpf. Is there any method which can hide a specific node? I know there is the 'IsVisible' property for Nodes and Edges but it only sets its visibility without affecting its size. For example, this code:

foreach (Node t in mysubgraph.Nodes) t.IsVisible = false;
gViewer.DrawingPanel.Invalidate();

correctly hides my nodes, but the size of mysubgraph remains the same, as if the invisible nodes still occupy the same area.

Where are the dlls?

Hi, i would like to use MSAGLwith Powershell. On the Frontpage it says:

> The package contains the following:
>     Layout engine (Microsoft.MSAGL.dll)
>     Drawing module (Microsoft.MSAGL.Drawing.dll)
>     Viewer control (Microsoft.MSAGL.GraphViewerGDIGraph.dll) 

But it does not.
If I have to somehow built them myself, a short step-by-step guide would be great, as I have really no clue on how to do that.
Thank you!

AddLeftRightConstraint doesn't work

Hi,

I'm trying to order de nodes inside my graph but,
I'm using for that (I have tried to ways)

        var settings2 = graph.LayerConstraints;

        settings2.PinNodesToSameLayer(new Node[]{ graph.FindNode("0_3"),
                                      graph.FindNode("0_1"),graph.FindNode("0_2")  });
        settings2.AddLeftRightConstraint (
                                        graph.FindNode("0_1"),
                                        graph.FindNode("0_2") ); // this crash

and this other way:

        Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings settings1 =
                           graph.LayoutAlgorithmSettings as
                                 Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings;
        graph.CreateGeometryGraph();
        settings1.AddLeftRightConstraint(graph.FindGeometryNode("0_1"), 
                                        graph.FindGeometryNode("0_2")); //this crash

In both of the I get the same message.

error1

The real problem is that after closing the alerts the Graph load with the correct order and presentation.

the only thing I need is to learn how to eliminate that Alert.

captura2

Thanks!!!

Test Failure: NestedDeepTranslationTest

This test fails for a couple of different reasons:

  • nodes[0] and nodes[1] aren't part of any cluster hierarchy that contains CreateCluster(nodes.Take(2), 10)
  • Clusters is a subtype of Node, but not all created clusters are added to the graph. I think they need to be right?
  • The assertion loop fails on nodes[0], nodes[1], and the edge from inside the translated cluster hierarchy to a node in CreateCluster(nodes.Take(2), 10) since deep translation uses EdgesIncomingToNodeWithDescendantSource.

Are all of these just problems with the test, or does DeepTranslation need to handle edges that aren't entirely in the cluster hierarchy slightly differently? (i.e. the source/destination of an edge isn't in the cluster hierarchy)

Or, should DeepTranslation even try to translate edge boundning boxes? Should the translated graph just be rerouted by the caller after DeepTranslation?

I don't need DeepTranslation to behave in any particular way myself, but failing tests annoy me. 😄

Thanks,
Bill

Subgraph nodes horizontally aligned

I'm trying to horizontal align subgraph nodes, without success. Code is:

`
using System.Linq;

graph.AddEdge("A", "B");
graph.AddEdge("A", "C");
graph.AddEdge("A", "D");
Subgraph hello = new Subgraph("hello");
graph.RootSubgraph.AddSubgraph(hello);
hello.AddNode(graph.FindNode("A"));
hello.AddNode(graph.FindNode("B"));
hello.AddNode(graph.FindNode("C"));
hello.AddNode(graph.FindNode("D"));
graph.LayerConstraints.PinNodesToSameLayer(hello.Nodes.ToArray());`

I suspect that by default all nodes of a subgraph belong to the same layer (please correct me if I'm wrong) and that's why my code doesn't work, while SameLayerSample does. But I cannot find a solution to horizontal align subgraph nodes, considering that graph LayerDirection has to beTB (TopBottom).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.