I would like to know how I can represent a Python dictionary using UML. This dictionary is an attribute of a class called Digraph. The keys are of type Node, and the values are of type Edge.
Asked
Active
Viewed 8,595 times
4
-
Duplicate of [What's the best way to generate a UML diagram from Python source code?](http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code) - Use the answers to simply populate the UML diagrams from your dictionary data. – Torxed Apr 28 '15 at 07:38
-
2@Torxed I disagree - this question has very little to do with Python and can be generally applied to any language (and their map/dictionary/hash/whatever) – Peter Uhnak Apr 28 '15 at 10:10
-
@peter Then this question should maybe not be tagged with Python. This could have been both asked and responded without the need of even mentioning the language itself. – Torxed Apr 28 '15 at 12:16
1 Answers
5
Qualified associations are useful for modeling maps/dictionaries.
See uml-diagrams.org for some examples.
You can also read the official UML (2.5) specs (see page 215)
And your particular problem can be represented as:
However note that this is only for nodes with single outgoing edges (its one-to-one mapping); if this wasn't your intention than the mapping would have to be Node to array of Edges. (and changing 1
into *
).

Peter Uhnak
- 9,617
- 5
- 38
- 51
-
1Though the official UML documentation has improved it's still not really usable for every-day-users of UML. Stay with uml-diagrams.org. – qwerty_so Apr 28 '15 at 11:26