vtkMutableDirectedGraph <https://www.vtk.org/doc/nightly/html/classvtkMutableDirectedGraph.html> has an API that is hopefully pretty intuitive with AddVertex, AddEdge, etc. You can also shallow-copy from the mutable graph into a DAG object, which performs a check, if it is important to verify you made a proper DAG. From the vtkDirectedAcyclicGraph docs <https://www.vtk.org/doc/nightly/html/classvtkDirectedAcyclicGraph.html> (I noticed some typos here, should read "DAG" instead of "tree"):
===== vtkDirectedAcyclicGraph is a read-only data structure. To construct a tree, create an instance of vtkMutableDirectedGraph. Add vertices and edges with AddVertex() and AddEdge(). You may alternately start by adding a single vertex as the root then call graph->AddChild(parent) which adds a new vertex and connects the parent to the child. The tree MUST have all edges in the proper direction, from parent to child. After building the tree, call tree->CheckedShallowCopy(graph) to copy the structure into a vtkDirectedAcyclicGraph. This method will return false if the graph is an invalid tree. ===== As for rendering in ParaView, you the following example shows how to use vtkGraphToPolyData, but this is not exposed in ParaView to my knowledge, I think you would need a plugin, or preprocess the graph into a vtkPolyData, save it, then load into ParaView. https://www.vtk.org/Wiki/VTK/Examples/Cxx/Graphs/GraphToPolyData Embedding from higher-dimensional coordinates into 2D or 3D does not have a VTK implementation that I know of, though PCA in VTK may be able to be used. If you want to do layout based on edge connectivity, there are some graph layout algorithms <https://www.vtk.org/doc/nightly/html/classvtkGraphLayoutStrategy.html> in VTK that could get you 2D or 3D coordinates. HTH, Jeff On Wed, Sep 13, 2017 at 11:58 AM Andy Bauer <[email protected]> wrote: > Hi Matthieu, > > There isn't a Catalyst example for graphs but it shouldn't be too hard to > make. I'm not very familiar with the vtkGraph and derived classes but if I > were to to try doing that I'd just see how the graph object is generated in > some filter that generates one (look in the RequestData() method). > > As for visualizing graphs in ParaView, hopefully someone else on the list > can provide insight on doing that. > > Best, > Andy > > On Wed, Sep 13, 2017 at 11:38 AM, Dorier, Matthieu <[email protected]> > wrote: > >> Hi, >> >> >> I would like to use Catalyst to visualize a distributed directed graph. >> Each node of the graph is characterized by an id (not necessarily >> contiguous, as some nodes are added and removed during the execution) and a >> list of connections (ids of "friends"). >> >> >> The nodes can be assigned coordinates in a 2D or a 3D space. >> >> >> Do you have an example of adaptor for that? >> >> >> Also if I want to use coordinates in higher dimensions, would I need to >> project to a 3D subspace or is there a way for ParaView to figure out a >> layout to display the graph? >> >> >> Thanks, >> >> >> Matthieu >> >> _______________________________________________ >> Powered by www.kitware.com >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Please keep messages on-topic and check the ParaView Wiki at: >> http://paraview.org/Wiki/ParaView >> >> Search the list archives at: http://markmail.org/search/?q=ParaView >> >> Follow this link to subscribe/unsubscribe: >> http://public.kitware.com/mailman/listinfo/paraview >> >> > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Search the list archives at: http://markmail.org/search/?q=ParaView > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/paraview >
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/paraview
