Consider a mixed graph G1 stored in GraphML file:

<graph edgedefault="directed">
    <node id="v1"/>
    <node id="v2"/>
    <node id="v3"/>
    <node id="v4"/>
    <edge source="v1" target="v2"/>
    <edge source="v1" target="v3"/>
    <edge source="v2" target="v4"/>
    <edge source="v2" target="v4" directed="false"/>

Importing it into Mathematica:

Import["G1.graphml", VertexLabels -> Automatic]

produces a directed (i.e. not mixed) graph:

enter image description here

which does not match the graph described in the GraphML file.

Am I missing something obvious here? Is this a bug, and if so, is there a way around it?

  • 2
    $\begingroup$ That looks like a bug to me. Not the first one related to Graph as @Szabolcs may confirm. $\endgroup$ – Henrik Schumacher Aug 23 '18 at 6:22
  • $\begingroup$ I did find GraphML handling to be less than ideal ... a practical solution may be reading the GraphML file as XML and parsing it manually. It shouldn't take more than 30 minutes, perhaps an hour if you're not fluent in these features yet. You can also try converting the GraphML to another format using an external tool, but unfortunately Mathematica has issues with most graph formats ... $\endgroup$ – Szabolcs Aug 23 '18 at 8:11
  • $\begingroup$ That's what I have resorted to - parsing GraphML file as an XML file manually, since Mathematica's functionality looks so unreliable that it seems that one has to be cautious even when working with simpler (i.e. purely directed or undirected) graphs. $\endgroup$ – montyynis Aug 28 '18 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.