6
$\begingroup$

Bug introduced in 9.0 and fixed in 11.3


Does anybody has an idea what is wrong with adding edge to an empty graph created by my custom function?

DiscreteGraph[n_]:=GraphComplement[CompleteGraph[n]];
EdgeAdd[DiscreteGraph[5],1<->2]

Note that the following works:

EdgeAdd[Graph[Range[5],{}],1<->2]

as well as the call with "graph-as-picture":

$\endgroup$
4
  • 2
    $\begingroup$ It's just one of the outrageous Graph-bugs that Wolfram hasn't fixed for years. I reported these types of failures multiple times. Please write to Wolfram Support and report it yourself. The only way they'll do something about it is if more people report it. Or maybe they've already abandoned all the Graph stuff!? Sometimes I really have the impression that they did!! $\endgroup$
    – Szabolcs
    Oct 11, 2017 at 14:14
  • 2
    $\begingroup$ The usual workaround to this kind of problem is to force the graph into another internal representation. There are many ways, such as g = Uncompress@Compress[g] or g = Graph[VertexList[g],EdgeList[g]] (loses properties). Then EdgeAdd won't fail. $\endgroup$
    – Szabolcs
    Oct 11, 2017 at 14:15
  • $\begingroup$ Thanks for making clear the situation. Here I add another cherry at the tart top: T=Graph[{1<->2,1<->3,3<->4,1<->5,5<->6,6<->7}] GraphAutomorphismGroup[T] Seems not to work in version 11.2, but works in version 10!!! (and yes, reported to company) $\endgroup$ Oct 11, 2017 at 14:20
  • $\begingroup$ GraphAutomorphismGroup[T] works fine for me in 11.2 / OSX. The function is known to be buggy on the Raspberry Pi, but AFAIK it works fine on desktop platforms. The IGraph/M package has a function you can use instead: IGBlissAutomorphismGroup. Feel free to contact me with any feedback about this package (and please use the latest pre-release if you try it out). $\endgroup$
    – Szabolcs
    Oct 11, 2017 at 14:26

1 Answer 1

1
$\begingroup$

This is a bug.

As a workaround, you can force Mathematica to change the internal representation of the graph by passing it through a compound expression representation in some manner.

For example,

g = Uncompress@Compress[g]

or

g = Graph[VertexList[g], EdgeList[g]] (* loses properties like EdgeWeight! *)

Alternatively, create the graph in an incidence representation directly:

emptyGraph[n_Integer?NonNegative] := Graph[Range[n], {}]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.