I am currently writing a graph object in Swift, I see that there are different types of graphs, some that are undirected and some that are directed. Here are my questions :

  • Can a graph be both directed and undirected, is there a specific name for such graph?
  • What is the common approach to make an edge that would be bi-directionnal but whose weight depends on the direction you are following. Would it be acceptable to make an edge that hold two weights, one for each direction? Or should I create two edges?

Thank you.

  • 1
    $\begingroup$ I have never seen anyone try to have an undirected edge whose weight is different in each direction. If you want that, use two directed edges. $\endgroup$ Jun 17, 2016 at 13:46
  • $\begingroup$ @DavidRicherby Thank you, I'll use directed edges than, especially since all the documentation online will use that too. $\endgroup$ Jun 17, 2016 at 13:48

1 Answer 1


A graph that is both directed and undirected is called a Mixed graph.

All graph libraries that I know don't have direction dependent edge properties. Hence I would advise against introducing them if two directed edges do the job.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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