0. Name/username

1. Are you coming from C200 or C211? 

2. Did C211/C212 prepare you well for this class?

   If not what do you think is missing? 

In Computer Science we have five basic data models:

  (a) the list data model

  (b) the set data model

  (c) the tree data model

  (d) the relational data model

  (e) the graph data model

When you write a program you go through these stages:

  Choose data representation 

  Give examples

  Name, signature, purpose statement

  Choose template for your code

  Flesh code, test it
 
  Include battery of tests (unit testing)

Data representation is where it all starts. 

Team exercise:

https://www.cs.indiana.edu/classes/c211-dgerman/sum2016/queens/hobokennj.jpg

Task: 

Start in A and write down

  (a) the depth-first traversal of it

  (b) the breadth-first traversal of it

3:02-3:07

--

(a) A
    AB   AC   AD
    ABE  ACH  ADF
    ABEI      ADFG
    ABEIG     ADFGI
    ABEIGF    ADFGIE
    ABEIGFD   ADFGIEB

(b) A
    A B 
    A B A (not acceptable) 
    A B E 
    A B E B (not good)     
    A B E I 
    A B E I G 
    A B E I G F
    A B E I G F D 
    A C 
    A C H
    A D
    A D F 
    A D F G
    A D F G I
    A D F G I E
    A D F G I E B 

This is how I start: 

public class Example {
  public static void main(String[] args) {
    Graph a = new Graph(); 
    Vertex A = new Vertex("A"); 
    System.out.println( A ); 
    Vertex B = new Vertex("B"); 
    a.add(A); 
    a.add(B); 
    a.add(new Vertex("C")); 
    System.out.println( a );
  }
}


import java.util.ArrayList; 

public class Graph extends ArrayList<Vertex> {
  
}

public class Vertex {
  public String name; 
  public Vertex(String name) {
    this.name = name;  
  }
  public String toString() {
    return this.name;  
  }
}

public class Edge {
  
}

--

Later I make some changes: 

public class Vertex {
  public String name; 
  public Vertex(String name) {
    this.name = name;  
  }
  public String toString() {
    return this.name;  
  }
}

--

import java.util.ArrayList; 

public class Neighbors extends ArrayList<Vertex> {
  public Neighbors(Vertex[] v) {
    for (Vertex e : v) {
      this.add(e);  
    }
  }
}

--

import java.util.*; 

public class Graph extends HashMap<Vertex, Neighbors> {
  
}

--

public class Example {
  public static void main(String[] args) {
    Graph a = new Graph(); 
    Vertex A = new Vertex("A"); 
    Vertex B = new Vertex("B"); 
    Vertex C = new Vertex("C"); 
    Vertex D = new Vertex("D"); 
    Vertex E = new Vertex("E"); 
    Vertex F = new Vertex("F"); 
    Vertex G = new Vertex("G"); 
    Vertex H = new Vertex("H"); 
    Vertex I = new Vertex("I"); 
    Vertex[] c = new Vertex[] { B, C, D }; 
    Neighbors b = new Neighbors( c ); 
    // System.out.println( b ); 
    a.put(A, b); 
    System.out.println( a ); 
    a.put(B, new Neighbors( new Vertex[] { A, E } )); 
    System.out.println( a ); 
    a.put(C, new Neighbors( new Vertex[] { A, H } )); 
    a.put(D, new Neighbors( new Vertex[] { A, F } )); 
    a.put(E, new Neighbors( new Vertex[] { B, I } )); 
    a.put(F, new Neighbors( new Vertex[] { D, G } )); 
    a.put(G, new Neighbors( new Vertex[] { I, F } )); 
    a.put(H, new Neighbors( new Vertex[] { C } )); 
    a.put(I, new Neighbors( new Vertex[] { E, G } )); 
    System.out.println( a ); 
  }
}

--

Now I'm ready to write the code.