July 2015


Options: Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Joey Harrison <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Tue, 21 Jul 2015 12:14:01 -0400
text/plain (2642 bytes) , text/html (3435 bytes)
Hi Miriam,

Here are a couple suggestions:

1) Since your graph doesn't change, store a JUNG version and a MASON
Network version. Use the NetworkPortrayal2D to visualize it and do your
shortest path calls on the JUNG version.

2) To visualize the shortest path, create a separate Network on a separate
layer with all the same nodes, but only the edges contained in the shortest
path. When you draw the edges for that layer, make them orange, wide, and
mostly transparent and it will look like highlighting.

Hope that helps,

On Tue, Jul 21, 2015 at 9:44 AM, Tschanen Miriam <[log in to unmask]>

>  Dear all,
> I am currently in the process of writing a custom portrayal class that can
> display JUNG graphs and I have a couple of questions.
> First off, I realise that there is an example of how to do this linked on
> the MASON homepage, but that display class adds a lot of fluff that I do
> not need. For example, I will not need an algorithm to plan the graph
> layout, because all my nodes are already embedded in a 2D field before
> creating the graph. I use the graph only to store weighted connections
> between the nodes, and just need a portrayal class to draw those
> connections. As such this is very similar to how the native Network class
> works with NetwortPortrayal2D, but I would still like to use some of JUNG's
> features, like its shortes path algorithms. So what I'm trying to do is to
> write my own adaption of the NetwortPortrayal2D class that displays a JUNG
> Graph instead of a Network.
> While digging through the NetwortPortrayal2D code I noticed something
> strange. I found this line in the hitOrDraw method:
> if (edgemap.containsKey(edge)) continue;
>                     edgemap.put(edge, edge);
> I cannot for the live of me imagine why anyone would add an object to a
> HashMap as both key *and *value. Why not just use a set? Is this an
> oversight, or am I missing something crucial here?
> Also, my graph is static and does not change at all during the simulation,
> so there would be no reason to redraw it at every time step. I found a flag
> called immutableField in the FieldPortrayal class, is setting this value to
> true enough to prevent redrawing? Or is there something else I need to do?
> And finally, I would like to highlight certain edges during the
> simulation, e.g. the shortest path between two nodes for any pair of nodes
> selected by the user. What would be the easiest way to implement the
> highlighting? I'm not looking for a complete example, just some pointers to
> get me started. Can this be done without redrawing the entire graph?
> Thanks in advance for any help.
> Sincerely,
> Miriam Tschanen