Data Structure Inferences

Example: Directed Graph



class Node {
  Edge *tail;                   // tail of the list
public:
  Edge *getFirst(void);         // get the first Edge
  void add(Node *n, Edge *e);   // add edge to n
  ...
};
class Edge {
  Edge *next;                   // circular list
  Node *target;                 // source node not stored
public:
  Edge *next(void);             // next edge from the same node
  void remove(Node *n);         // remove edge from node n
  ...
};
Operations such as add(), remove(), or even next() need access
to both classes.

Different applications may need different styles.
Problem with aggregates, collections, and other data structures.