Recitation 8 - PowerPoint PPT Presentation

About This Presentation
Title:

Recitation 8

Description:

Predecessors, successors. Implementation. Centralized. Graph stores everything ... Iterator predecessors(Object node); Iterator successors(Object node) ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 14
Provided by: alle4
Learn more at: http://nms.lcs.mit.edu
Category:

less

Transcript and Presenter's Notes

Title: Recitation 8


1
Recitation 8
  • Godfrey Tan

2
Administrivia
  • Hand back Quiz 1 at end of section
  • PS 4 due next Monday, March 11
  • Use office hours, forum, zephry

3
Overview of 6.170
  • Specs Needed to tell other people what our code
    does
  • MDDs
  • Reason about modularity and reuse
  • Try to minimize dependencies
  • OMs
  • Reason about problems or the state of a program
  • Useful in examining your data model or analyzing
    constraints of your system
  • Testing Debugging
  • ADTs
  • Provides abstraction and way of solving problems
    by designing software that closely resembles the
    problem
  • AF/RI
  • Ability to reason locally about correctness
  • AF ? transformation between a COM to a POM tells
    us how what we are coding
  • RI ? properties and additional constraints for a
    COM tells us what should always hold about our
    data model
  • Rep Independence and Rep Exposure

4
Graph Requirements
  • Directed
  • Multi-graph
  • Dynamic add and remove nodes
  • Flexible works for other applications

5
Graph Operations
  • addNode, containsNode
  • addEdge, containsEdge
  • Traversal
  • Predecessors, successors

6
Implementation
  • Centralized
  • Graph stores everything
  • May or may not require Node class
  • Distributed
  • Graph stores Nodes
  • Node stores Edges

7
Implementation
  • Separate data and internal structures
  • Do not expose nodes and edges
  • Apps stores raw data associated with nodes and
    edges
  • Combine data and basic structures
  • Public Node and Edge classes
  • Apps associate customized data by extending Node
    and Edge classes

8
Centralized and Separate I
  • Graph
  • void addNode(Object nodeData)
  • void addEdge(Object from, Object to, Object
    label)
  • int containsNode(Object nodeData)
  • int containsEdge(Object from, Object to)
  • Iterator predecessors(Object node)
  • Iterator successors(Object node)
  • Iterator getNode()
  • Iterator getLabel(Object from, Object to)

9
Centralized and Separate II
  • Graph
  • Handle addNode(Object nodeData)
  • Handle addEdge(Object from, Object to, Object
    label)
  • int containsNode(Handle node)
  • int containsEdge(Handle edge)
  • Iterator predecessors(Handle node)
  • Iterator successors(Handle node)
  • Iterator getNode()
  • Iterator getLabel(Handle e)

10
Distributed and combined
  • Graph
  • void addNode(Node o)
  • boolean containsNode(Node o)
  • boolean containsEdge(Edge e)
  • Iterator predecessors(Node o)
  • Iterator successors(Node o)
  • Iterator getNode()
  • Iterator getLabel(Edge e)

11
Distributed and combined
  • Node
  • Graph graph
  • Edge addEdge(Node to, Object label)
  • Iterator getInEdges()
  • Iterator getOutEdges()
  • Edge
  • Node from, to Object label
  • Node getFrom()
  • Node getTo()
  • Object getLabel() void setLabel(Object label)

12
Problem Set 4
  • More POMs
  • AF (toString)
  • RI (checkRep)
  • Fixing your problems
  • Testing

13
Quiz
  • Avg 73.29744
  • StdDev 12.79
  • Other than minor fixes such as wrong addition,
    you must write a written request for re-grade.
Write a Comment
User Comments (0)
About PowerShow.com