1

I was trying to change this UML (class diagram) undirected graph representation to a directed graph, but I got stuck. What are the changes that have to be made and why?

enter image description here

JavaStudentPanic
  • 47
  • 1
  • 2
  • 10

2 Answers2

1

to make your graph directed the edges must have a direction, for that you can differentiate the starting and ending nodes :

enter image description here

The nodes and edges disappear when the graph disappears, so you can have compositions rather than aggregations

bruno
  • 32,421
  • 7
  • 25
  • 37
-1

For the original diagram: next to 2, you must specify {nonunique}

For both charts: the association from "graph" to "edge" is derived; both "node" from the same "edge" from the same "graph"

  • I do not understand at all your answer, and it seems not only me (the DV is not from me). Out of the fact by default an association is nonunique so your first part changes nothing, in what this is important to have directed edges ? The second part of your answer is even more obscure for me, `the association from "graph" to "edge" is derived` : it is not in OP diagram, or if your proposal is to have it derived how it is derived and in what that makes the edges directed ?. Please explain – bruno Mar 24 '21 at 16:30
  • **Out of the fact by default an association is nonunique** - OMG® Unified Modeling Language® (OMG UML®) Version 2.5.1 '7.8.8.5 Attributes': "isUnique : Boolean [1..1] = true" – user6580165 Mar 25 '21 at 05:57
  • **the association from "graph" to "edge" is derived** context Edge::directedGraph derive: from.directedGraph **both "node" from the same "edge" from the same "graph"** context Edge inv: from.directedGraph=to.directedGraph – user6580165 Mar 25 '21 at 06:37
  • ah yes you are right, *isUnique* is true by default, thank you. But that changes nothing about the fact the edges are directed or not, that just allows to have a reflexive edge which is not the question. – bruno Mar 25 '21 at 07:10
  • and for the derivation it seems you still want to have reflexive edges, so this out of out subject. A directed graph has directed edges, so edges having a starting node and an ending node (when you draw the edge : `startnode -----> endode`, I do not speak about to draw the class diagram but the graph itself). This is what I do in my answer where the starting and ending nodes are known. A non directed edge connects two nodes without distinction between these nodes (when you draw the edge : `node1-----node2`). For me you are out of subject, better you delete your answer. Good continuation anyway – bruno Mar 25 '21 at 07:45
  • On the original diagram graph is Irreflexive or anti-reflexive (it is not right). On your diagram graph is non-reflexive (it is right). – user6580165 Mar 25 '21 at 09:43
  • I wanted to say: an edge connects the nodes of one graph (context Edge inv: from.directedGraph=to.directedGraph); an edge belongs to the same graph whose nodes are connected by (context Edge::directedGraph derive: from.directedGraph) – user6580165 Mar 25 '21 at 09:50