I have created a graph with undirected edges, and I'm trying to import it into Mathematica. However, when I import it, I get directed edges.

g = Import["document.graphml", "Graph",  VertexLabels -> "Name"]
  • 1
    $\begingroup$ Please, post the example you are trying to import and any relevant information. $\endgroup$
    – Sektor
    Sep 10, 2015 at 20:05
  • $\begingroup$ What is in your graphml file allows Mathematica to distinguish a non-directed edge from a directed edge? Also, it is easy to change directed edges into undirected edges by post-processing the imported graph. Did you try that? $\endgroup$
    – m_goldberg
    Sep 10, 2015 at 20:30

2 Answers 2

g = Graph[{1 -> 2, 2 -> 3, 3 -> 1}, VertexLabels -> "Name"];
h = UndirectedGraph[g, VertexLabels -> "Name"]

I said in a comment that is easy to change directed edges into undirected edges. Here is an example offered as proof-of-concept.

g = Graph[{DirectedEdge[a, b], DirectedEdge[b, c], DirectedEdge[c, a]}]
h = Graph[EdgeList[g] /. DirectedEdge -> UndirectedEdge]
    Graph[{a, b, c}, 
      {UndirectedEdge[a, b], UndirectedEdge[b, c], UndirectedEdge[c, a]}]]

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