0

How do I represent a graph data-type in a class diagram

Class Diagram: http://www.uml-diagrams.org/class-diagrams.html

Do I have to specify how graph data-type is implemented? Or is there a symbol to denote a graph?

user2136334
  • 648
  • 7
  • 16
  • What do you mean with the term "graph data-type"? Do you have a specific example in mind? A graph consists of nodes and edges where nodes are objects (or data values) of some type, and edges are binary relationships (links) between two nodes. – Gerd Wagner Jan 06 '15 at 18:47
  • It depends on what you mean by "data-type". How does your system define a graph? As an object, or perhaps as a series of binary data? Or something else? – BobRodes Jan 07 '15 at 01:52

1 Answers1

0

UML itself includes diagrams that are graphs (state machine diagrams, activity diagrams) but will not provide what you are expecting.

UML is originally conceived for object-oriented programming, not programming in general. It will allow you to represent object-oriented features, not general programming features (as graphs are not object-oriented features).

So you will be able to represent a Graph class as a class, not as a graph data type. Graph are abstract data types, it is up to the programmer to implement (it will be highly related to the way you are programming, you can manage graphs without OOP).

bdulac
  • 1,686
  • 17
  • 26
  • 1
    Not to start a flamewar, but UML isn't about OO programming. UML is about modelling software intensive systems. From the [UML 2.5 Beta2 specification](http://www.omg.org/spec/UML/2.5/Beta2/PDF) `The objective of UML is to provide system architects, software engineers, and software developers with tools for analysis, design, and implementation of software-based systems as well as for modeling business and similar processes.` – Geert Bellekens Jan 07 '15 at 11:47
  • Well, this is more a troll than anything: what you make the OMG (first, in OMG there is Object) say about UML is not honest. In the OMG's perspective, UML is an element of the [MOF](http://en.wikipedia.org/wiki/Meta-Object_Facility). "Visualizing, specifying constructing and documenting object-oriented systems is exactly the purpose of the Unified Modeling Language" says [The User Guide](http://www.worldcat.org/oclc/799556306) (p. 11, why we model). Definitely, OMG's documents are too large to be understood clearly, the original authors where more efficient on that point. – bdulac Jan 07 '15 at 14:34
  • @bdulac: UML is about OO analysis, OO design and OO implementation modeling, but not limted to OOP. – Gerd Wagner Jan 07 '15 at 20:28
  • Well, on the latest point, anyone is free to use UML for anything. But what I meant in a few words was that the initial authors and the OMG are focusing on OOP. So originally UML is about OOP, but you are free to have your own definition :-). Any alternative reference is welcome, otherwise I definitely consider this is a troll. – bdulac Jan 09 '15 at 09:17
  • 1
    @GeertBellekens in the document you cite, the following paragraph is: "The initial versions of UML (UML 1) originated with three leading object-oriented methods (Booch, OMT, and OOSE), and incorporated a number of best practices from modeling language design, object-oriented programming, and architectural description languages. Relative to UML 1, this revision of UML has been enhanced with [... and] a greatly improved capability for modeling large- scale systems. One of the primary goals of UML is to advance the state of the industry by enabling object visual modeling tool interoperability." – bdulac Jan 09 '15 at 09:37
  • @bdulac This question apparently has already been answered on this very site: http://stackoverflow.com/questions/26212374/are-uml-diagrams-only-for-object-oriented-approach – Geert Bellekens Jan 09 '15 at 11:39
  • Well, an accepted answer on Stackoverflow does not mean it is right: just a question of reference. I understand and accept that some people use UML for other things than OOP but this is not the original idea. To conclude all, I will change my answer: "about object-oriented programming" will become "originally conceived for object-oriented programming". I guess we all agree in the end and it will be fine for anyone. – bdulac Jan 09 '15 at 13:00
  • ... if UML was REALLY meant for programming in general, there would be a way for properly modeling graphs independently from OOP, isn't it ? ;-) To be fair, using UML for general programming is possible because some diagrams like state machine and activity don't include OOP features. I answered in the other exchange that way. Perhaps was it the original authors intention, who knows, they don't say it in the books. Who cares, it seems to me people only use UML for OOP (don't know any C programmer using UML)... – bdulac Jan 09 '15 at 13:23
  • ...regrets for my last sentence: just discovered [that exchange](http://stackoverflow.com/questions/27846585/linux-device-drivers-3ed-file-io-how-to-influence-scheduling-with-explanatory) – bdulac Jan 09 '15 at 13:35