Group Abstract Group Abstract

Message Boards Message Boards

0
|
317 Views
|
7 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Animation of building up a graph

Posted 1 month ago

I have a graph that has nodes and (weighted, not directed, but this is not essential to be displayed) edges that is gradually built up in a procedural loop. How can I show this in an animation? Is there a way to make Animate[] use the looping parameter, which is also used to run the code to build the graph? Or is there some other way? I haven't debugged my program yet, so I haven't posted it here. I was also hoping to use the graphical animation to debug it.

POSTED BY: Iuval Clejan
7 Replies
Posted 1 month ago

Super helpful, thanks. However, still 2 issues 1. When I use VertexAdd, I can't just add a label for the vertex added. I have to add all of the labels, because it erases previous labels. Not a big deal 2. Big deal: the display keeps jumping between different parts of the graph, switching their positions. I know it's trying to optimize something visually, but it's quite terrible. Is there a way to turn off the optimization.?I include a test file so you can see what I mean.

POSTED BY: Iuval Clejan
Posted 1 month ago

Also a third issue is I would like to have edge weights displayed proportional to line thickness (I have a matrix that keeps track of these weights, but I didn't use it in the example above), but I don't know how to do that.

POSTED BY: Iuval Clejan

Just an idea: start with the full final graph, but colored white, or very light. Then switch the colors on in succession.

POSTED BY: Gianluca Gorni
Posted 1 month ago

That worked, thanks!

POSTED BY: Iuval Clejan
Posted 26 days ago

Keeping the previous format, is there anyway to have varying edge widths whenever I use EdgeAdd? I tried, but it doesn't seem to work.

. I can get nodes to be different sizes, but not edges, probably misunderstanding the syntax.

POSTED BY: Iuval Clejan
Posted 24 days ago

Never mind, I figured out the syntax.

POSTED BY: Iuval Clejan

You could use Monitor around whatever looping construct you're using for your code.

As a quick example here I just delete one edge at a time from a complete graph and show each step:

g = CompleteGraph[8];
Monitor[
 Do[
  edge = EdgeList[g] // RandomChoice;
  g = EdgeDelete[g, edge];
  Pause[0.25];
  ,
  16],
 g]
POSTED BY: David Trimas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard