I need to display a DAG (directed acyclic graph), which is basically a Treeview, except children can have multiple parents. Any clue on a control or method to implement this in Visual Basic 2008?
Tekito 0 Junior Poster in Training
Dani AI
Generated
Short summary and practical next steps.
wanted a TreeView-like display for a directed acyclic graph (nodes with multiple parents). As suggested, a diagram/graph control is usually the simplest route — a true graph renderer handles shared nodes, layout and connectors for you. If you need alternatives, here are practical options and a minimal, actionable plan.
Pick a layout engine or diagram SDK: MSAGL (Microsoft Automatic Graph Layout) gives .NET layout + viewer controls for WinForms/WPF and is a good first choice for programmatic layout. (github.com) Graphviz is the classic open-source layout engine (DOT) you can call as an external process and consume SVG/coordinates if you must keep to older runtimes. (graphviz.org) For production, mature commercial SDKs (yFiles, DevExpress/Syncfusion diagram controls, etc.) provide drag/drop, automatic routing and professional polish. (yworks.com) Use a .NET graph library (QuikGraph/QuickGraph) for the in-memory model and algorithms (topological sort, cycle checks). (github.com)
Minimal implementation plan
- Keep a single node object per logical node (unique ID) and an edge list (source,target).
- Run a DAG check/topological sort (library or simple DFS).
- Feed nodes/edges into a layout engine (MSAGL/Graphviz) to compute X/Y positions.
- Render with a viewer control (best) or your own WinForms/WPF drawing code and draw connectors between computed positions.
A tiny VB.NET WinForms paint loop (concept):
Protected Overrides Sub OnPaint(e As PaintEventArgs)
MyBase.OnPaint(e)
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
For Each ed In edges
Dim a = nodes(ed.Item1), b = nodes(ed.Item2)
e.Graphics.DrawLine(Pens.DarkGray, a.X, a.Y, b.X, b.Y)
Next
For Each n In nodes.Values
e.Graphics.FillEllipse(Brushes.White, n.X-16, n.Y-16,32,32)
e.Graphics.DrawEllipse(Pens.Black, n.X-16, n.Y-16,32,32)
e.Graphics.DrawString(n.Text, Me.Font, Brushes.Black, n.X+18, n.Y-8)
Next
End Sub Notes and cautions: avoid trying to fake multiple parents with duplicated TreeView nodes (state becomes inconsistent). For large graphs use semantic zoom/tiling or GraphMaps-style rendering; enable double-buffering and only redraw visible regions. If you target legacy VB.NET 2008/.NET 3.5, prefer external Graphviz or pick SDK versions compatible with that framework (or plan for a small compatibility wrapper).
Jeff-Bennett 0 Newbie Poster Team Colleague
I need to display a DAG (directed acyclic graph), which is basically a Treeview, except children can have multiple parents. Any clue on a control or method to implement this in Visual Basic 2008?
You might look at our MetaDraw component
MetaDraw will allow you to create diagrams such as DAG.
The syntax / mechanism for building the diagram would be different than from a TreeView, but far more flexible. You can add your nodes anywhere and present as text, or shapes or images and then have connecting lines of various styles and colors with optional arrow heads of various styles. You can even allow the user
to drag the nodes while the connections are automatically maintained.
I will try to post a web based sample with sample code later today at
http://
I would be happy to discuss with you further.
Just drop me a note at Jeff [ a t ] bennet-tec [ dot ] com
* Bennet-Tec Information Systems, Inc
* 50 Jericho Tpk, Jericho, NY 11753
* Phone 516 997 5596, Fax - 5597
*
RELIABLE Component Software
and Custom Software Development Services
* Expert Systems * Text Processing
* Databases * Interactive Web Sites
* Diagramming, Drawing, Hotspot Graphics
* Data Input & Data Presentation Systems
* Desktop Windows, Tablets, Pocket PCs
TList™ / ALLText™ / MetaDraw™ / Web Signature™
-------------------------------------------------------------------------------------
This message was sent to you by Bennet-Tec Support System
--------------------------------------------------------------------------------------
Jeff-Bennett 0 Newbie Poster Team Colleague
Correction,
the web sample is located at
www.bennet-tec.com/BTProducts/MetaDraw/WebSamples/Directed_Acyclic_Graph/Directed_Acyclic_Graph.htm
To see the code used to implement this sample, right click and select View Source.
I would be happy to discuss with you further.
Edited by pritaeas because: Removed fake signature.
Tekito 0 Junior Poster in Training
Thanks. I took a look and it would probably do the trick (and then some). Depending on whether I can find an available tool in Visual Studio (which is looking unlikely) and, of course, if my boss approves, we might be interested.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.