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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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 *
).