Jawab MSAGL heuristic layout

All Replies

  • Monday, November 02, 2009 11:05 PM
    Owner
     
     Answered
    I think I did reply to this question at the referenced thread. I am probably missing something.
    Thanks,
    Lev
    Lev Nachmanson
  • Tuesday, November 03, 2009 7:49 AM
     
     
    Hi Lev,

     I am sorry that i was not clear from my side. Graph.Attr.AspectRatio is a expecing a double value and by setting that property how can i achieve a graph as mentioned in the ftp://ftp.research.microsoft.com/pub/tr/TR-2007-72.pdf Figure 1.

    I tried setting this property to some random values but it increases the distance between the nodes in a single row. Do i need to address any other property along with the AspectRation property?

    Thanks
    Rub
  • Tuesday, November 03, 2009 3:55 PM
    Owner
     
     Answered
    Hi Rub,
    I see. To achieve the effect of this picture you need to set GeometryGraph.SimpleStretch=false;
    If SimpleStretch is set to true then just a simple transformation is applied to get the required aspect ratio.
    Thanks,
    Lev


    Lev Nachmanson
  • Tuesday, August 02, 2011 11:03 PM
     
     

    Hello everybody,

    I stumble over the same problem, but I can't figure out *when* I have to set the AspectRatio and SimpleStrech properties. Could someone provide a more complete example?

    And another question: What is the unit in which MSAGL "thinks"? In what unit are properties like LabelMargin, XRadius and so on given and settable?

     


    Best Regards, Stefan Falk
  • Wednesday, August 03, 2011 3:31 PM
    Owner
     
     Answered

    Hi Stefan,

    To change the SimpleStretch property one needs to have access to the GeometryGraph object. I modified NodesWithImagesSample by adding these twlines

    //setting the aspect ratio

    geomGraph.SimpleStretch=false;

    geomGraph.AspectRatio = 1;

    // aspect ratio is set

    geomGraph.CalculateLayout();

    ============

    There is no good API to set it on the level of Microsoft.Drawing.Graph. I believe I did not provide such an API because I was not satisfied with the quality of the layouts produced by the algorithm when SimpleStretch is false.

     

    Answering the question on the units: MSAGL draws in the same units as GDI+. Those are "logical units". The real size of a unit is defined by the device DPI ( Dots Per Inch).

     

     

     


    Lev Nachmanson
  • Thursday, August 11, 2011 9:22 AM
     
      Has Code

    Hello Lev,

    oh, an answer from the creator of these fine algorithms himself - Chapeau!

    I still do not see any difference in the diagrams created. I use a PowerShell script, here is a code excerpt:

    $graph.Attr.LayerDirection = $layerDirection
    $graph.Attr.AspectRatio = 1.3
    $graph.GeometryGraph.SimpleStretch = $false
    $renderer = New-Object Microsoft.Msagl.GraphViewerGdi.GraphRenderer($graph)
    $renderer.CalculateLayout()
    $scale = 2
    $bitmap = New-Object System.Drawing.Bitmap(($scale * [int]$graph.Width), ($scale * [int]$graph.Height))
    $renderer.Render($bitmap)
    
    

    However, this does not produce any differend graph if I ommit or keep the statements with set the AspectRatio and SimpleStrech properties. Do I have to change the order of the statements?

     


    Best Regards, Stefan Falk
  • Thursday, August 11, 2011 4:22 PM
    Owner
     
     

    Hi Stefan,

    This will not work since under the hood GraphRenderer will create a new GeometryGraph and your settings will be forgotten.

    The source of GraphRenderer is inside of the distribution, so you should have it. GraphRenderer in the and calls  GViewer.LayoutAndDGraph . You can also see how  GViewer.LayoutAndDGraph works. So, for your experiments you need to change method LayoutAndDGraph to take your settings into account, just before the call to

    gleeGraph.CalculateLayout();

    Thanks,

    Lev


    Lev Nachmanson