[vtkusers] vtkGraph: Specifying distances between all pairs of nodes for Force Directed placement

Aashish Chaudhary aashish.chaudhary at kitware.com
Mon Oct 25 10:08:34 EDT 2010


I don't remember on top of my head if there is an easy way to do this.
But one way you could have this by having virtual edges, assign the
weight / distance as Eric suggested and have another array for
visibility (0 or 1) lets say which can be used for opacity. So all the
virtual edges could be assigned visibility = 0.

Hope this helps,
Aashish

On Mon, Oct 25, 2010 at 10:02 AM, Amina Shabbeer
<aminashabbeer at gmail.com> wrote:
> Yes, Im sorry I should have specified. I need to specify weights/distances
> between nodes that are not connected by edges as well. I can use the edge
> weight strategy for neighbours, but what do I do for nodes not connected by
> edges?
>
> thanks,
> amina
>
> On Mon, Oct 25, 2010 at 8:46 AM, David Doria <daviddoria at gmail.com> wrote:
>>
>> On Mon, Oct 25, 2010 at 8:39 AM, Eric E. Monson <emonson at cs.duke.edu>
>> wrote:
>> >
>> > Hello Amina,
>> >
>> > The graph layout strategies (at least the force-directed types I'm
>> > familiar with) work with the concept of an edge "weight" instead of a
>> > distance. So, because a strong weight would tend to end up as a short
>> > distance after the layout, you might be able to get your desired results by
>> > inverting your distances to make weights. I hope you realize, though, that
>> > it's impossible to flatten an arbitrary graph into 2D while specifying all
>> > of the node-node distances, so some of the spacings may not end up exactly
>> > as you hope.
>> >
>> > One way to construct the graph is to create a table with three columns.
>> > The first two contain indices that specify which vertices edges will run
>> > between, and the third column is the edge weight. Then, use vtkTableToGraph
>> > to create the graph (and the graph edges will contain the weight). If column
>> > 1 is called "index1", and column 2 is called "index2" (and column 3 is
>> > called "weight"), you would run something like (this is Python):
>> >
>> > tgraph = vtk.vtkTableToGraph()
>> > tgraph.SetInput(table)
>> > tgraph.AddLinkVertex('index2', 'stuff', False)
>> > tgraph.AddLinkVertex('index1', 'stuff', False)
>> > tgraph.AddLinkEdge('index2', 'index1')
>> >
>> > Other examples are linked from the doc page:
>> > http://www.vtk.org/doc/nightly/html/classvtkTableToGraph.html
>> >
>> > Hope this helps get you started,
>> > -Eric
>>
>>
>> I believe Amina is looking to also specify distances between vertices
>> that do not have an edge between them:
>>
>> >  "given distances between all pairs of nodes"
>>
>> Is that correct Amina?
>>
>> David
>
>
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



-- 
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com



More information about the vtkusers mailing list