title: Object Oriented implementation of graph data structures
body: <p>I have been reading quite a bit graph data structures lately, as I have intentions of writing my own UML tool. As far as I can see, what I want can be modeled as a simple graph consisting of vertices and edges. Vertices will have a few values, and will so best be represented as objects. Edges does not, as far as I can see, need to be neither directed or weighted, but I do not want to choose an implementation that makes it impossible to include such properties later on.</p>
  
  <p>Being educated in pure object oriented programming, the first things that comes to my mind is representing vertices and edges by classes, like for example:</p>
  
  <pre><code>Class: Vertice
      - Array arrayOfEdges;
      - String name;
  
  Class: Edge
      - Vertice from;
      - Vertice to;
  </code></pre>
  
  <p>This gives me the possibility to later introduce weights, direction, and so on. Now, when I read up on implementing graphs, it seems that this is a very uncommon solution. Earlier questions here on Stack Overflow suggests adjacency lists and adjacency matrices, but being completely new to graphs, I have a hard time understanding why that is better than my approach.</p>
  
  <p>The most important aspects of my application is having the ability to easily calculate which vertice is clicked and moved, and the ability to add and remove vertices and edges between the vertices. Will this be easier to accomplish in one implementation over another?</p>
  
  <p>My language of choice is Objective-C, but I do not believe that this should be of any significance.</p>