0
$\begingroup$

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.

$\endgroup$
  • 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$ – David Richerby Jun 17 '16 at 13:46
  • $\begingroup$ @DavidRicherby Thank you, I'll use directed edges than, especially since all the documentation online will use that too. $\endgroup$ – Trevör Jun 17 '16 at 13:48
3
$\begingroup$

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.

$\endgroup$

Your Answer

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

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