Message Boards Message Boards

5
|
5898 Views
|
1 Reply
|
6 Total Likes
View groups...
Share
Share this post:

Multigraphs and graph properties—will Mathematica support these?

Posted 7 years ago

A multigraph is a graph that has more than one edge between the same two vertices. An example is

g = Graph[{1<->2, 1<->2}]

Mathematica seems to take a very general approach to graphs. For example, it even supports "mixed graphs" which have both directed and undirected edges within the same graph. Trying to be this general seems dangerous to me because it makes implementing graph algorithms difficult, and leaves room for a lot of error. And what is the benefit? I am wondering if there is anyone here who truly needs such "mixed graphs". Which application do these graphs enable in Mathematica that couldn't be modelled with a simple directed graph which has directed edges going both ways between some vertices? I.e. instead of Graph[{1<->2, 2->3}], use Graph[{1->2, 2->1, 2->3}].

At the same time, other very useful applications seem to be impossible due to fundamental design flaws. Mathematica supports multigraphs, and graph properties. But how can I distinguish between two edges running between the same vertices?

I can set different weights for these two edges:

g = Graph[{1<->2, 1<->2}, EdgeWeight->{1,2}]

And I can retrieve them in bulk:

In[298]:= PropertyValue[g, EdgeWeight]
Out[298]= {1, 2}

But how can I retrieve them individually?

In[299]:= PropertyValue[{g, 1 <-> 2}, EdgeWeight]
Out[299]= 1

There is no way to distinguish between the two edges.

How can I set custom properties for them separately? Unlike EdgeWeight, custom properties are not stored as a list. Instead they are assigned to edges individually as a set of Rules. But the notation does not allow us to distinguish between some of the edges (i.e. the LHS of the Rule).

How can I colour them separately when visualizing the graph? This, in particular, seems to be a much-requested feature: see 1 2 3 4 and more on StackExchange. The last time I needed this, I just went straight to graphviz.

Are there any plans to address this shortcoming with the design of Graph? Are there plans to make property handling robust and practically usable?

POSTED BY: Szabolcs Horvát

It would be really Great to have This sorted out. As you are stating i also needed to escape to alternatives. It's such a pity that this has not been implemented.

POSTED BY: l van Veen
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract