1 / 9

Graph Class Diagram

Graph Class Diagram. Graph Invariant. ReadOnlyGraph: nodes().empty() implies edges().empty(). Graph:. ReadOnlyGraphImplementation:. ListSetGraph: nodes().empty() implies edges().empty() && the_nodes != null && the_edges != null.

dstpierre
Download Presentation

Graph Class Diagram

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graph Class Diagram

  2. Graph Invariant ReadOnlyGraph: nodes().empty() implies edges().empty() Graph: ReadOnlyGraphImplementation: ListSetGraph: nodes().empty() implies edges().empty() && the_nodes != null && the_edges != null HashTableSetGraph: nodes().empty() implies edges().empty() && the_nodes != null && the_edges != null

  3. @post nodes().empty() @post edges().empty() public HashtableSetGraph() { the_nodes = new HashtableSet(); the_edges = new HashtableSet(); } @post nodes().empty() @post edges().empty() public ListSetGraph() { the_nodes = new ListSet(); the_edges = new ListSet(); } HashTable/Set ListGraph

  4. ReadOnlyGraph @post $ret != null public ReadOnlySet nodes(); @post $ret != null public ReadOnlySet edges(); @pre node != null @post $ret != null @post !nodes().has(node) implies $ret.empty() public ReadOnlySet outgoing_edges(Node node);

  5. ReadOnlyGraph @pre label != null @post $ret != null implies nodes().has($ret) && label.equals($ret.label()) public Node find_node(Object label); @post label != null @post $ret != null implies edges().has($ret) && label.equals($ret.label()) public Edge find_edge(Object label); @pre node != null @pre label != null @post !nodes().has(node) implies $ret == null @post $ret != null implies edges().has($ret) && node.equals($ret.from()) && label.equals($ret.label()) public Edge find_outgoing(Node node, Object label);

  6. Graph:add_edge @pre edge != null @post nodes().has(edge.from()) @post nodes().has(edge.to()) @post !nodes().empty() @post edges().has(edge) @post !edges().empty() @post outgoing_edges(edge.from()).has(edge) //@post $prev(! edges().has(edge)) implies edges().count() == $prev(edges().count())+ 1 //@post $prev(edges().has(edge)) implies edges().count() == $prev(edges().count()) public void add_edge(Edge edge);

  7. Graph:add_node @pre node != null @post nodes().has(node) @post !nodes().empty() //@post $prev(!nodes().has(node)) implies nodes().count() == $prev(nodes().count()) + 1 //@post $prev(nodes().has(node)) implies nodes().count() == $prev(nodes().count()) public void add_node(Node node);

  8. ReadOnlyGraphImplementation /** Find an edge with a given label in the given sequence. * @pre edges != null * @pre label != null */ protected Edge edge_search(ReadOnlySet edges, Object label)

  9. For any g : GRAPH[NODE-LABEL, EDGE-LABEL], n, n1, n2 : NODE[NODE-LABEL], e : EDGE[NODE-LABEL, EDGE-LABEL]: A5 nodes (make-graph) = emptyset A6 edges (make-graph) = emptyset A7 nodes (add-node (g, n)) = extend (nodes (g), n) A8 edges (add-node (g, n)) = edges (g) A9 nodes (add-edge (g, e)) = extend (extend (nodes (g), edge-from (e)), edge-to (e)) A10 edges (add-edge (g, e)) = extend (edges (g), e) A11 outgoing-edges (make-graph, n) = emptyset A12 not has (nodes (g), n) outgoing-edges (add-node (g, n), n) = emptyset A13 outgoing-edges (add-node (g, n1), n2) = outgoing-edges (g, n2) A14 n = edge-from (e)  outgoing-edges (add-edge (g, e), n) = extend (outgoing-edges (g, n), e) A15 n ≠ edge-from (e)  outgoing-edges (add-edge (g, e), n) = outgoing-edges (g, n)

More Related