Graph API (How I Did It) 1-Jan-19.

Slides:



Advertisements
Similar presentations
Singleton vs utility class  at first glance, the singleton pattern does not seem to offer any advantages to using a utility class  i.e., a utility class.
Advertisements

Mutability SWE 332 Fall 2011 Paul Ammann. SWE 3322 Data Abstraction Operation Categories Creators Create objects of a data abstraction Producers Create.
Inheritance Part I. Lecture Objectives To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass.
Trees. 2 Definition of a tree A tree is like a binary tree, except that a node may have any number of children Depending on the needs of the program,
23-May-15 Polymorphism. 2 Signatures In any programming language, a signature is what distinguishes one function or method from another In C, every function.
Abstract Data Types II. 2 Sufficient operations Operations on an ADT are sufficient if they meet all the requirements They must be able to create all.
CS2200 Software Development Lecture: Object class A. O’Riordan, 2008.
Reduction Techniques Restriction Local Replacement Component Design Examples.
hashing1 Hashing It’s not just for breakfast anymore!
1 Java Object Model Part 2: the Object class. 2 Object class Superclass for all Java classes Any class without explicit extends clause is a direct subclass.
Abstract Data Types II. 2 Sufficient operations Operations on an ADT are sufficient if they meet all the requirements They must be able to create all.
Abstract Data Types II. Sufficient operations Operations on an ADT are sufficient if they meet all the requirements –They must be able to create all the.
13-Jul-15 Abstract Data Types. 2 Data types I We type data--classify it into various categories-- such as int, boolean, String, Applet A data type represents.
CS-2851 Dr. Mark L. Hornick 1 Tree Maps and Tree Sets The JCF Binary Tree classes.
Chapter 7 More Lists. Chapter 7: More Lists 7.1 – Circular Linked Lists 7.2 – Doubly Linked Lists 7.3 – Linked Lists with Headers and Trailers 7.4 – A.
COSC 1P03 Data Structures and Abstraction 4.1 Abstract Data Types The advantage of a bad memory is that one enjoys several times the same good things for.
Complex objects How might you design a class called NestedRects of graphical objects that look like this? Requirements for the constructor: –Like many.
Course: Object Oriented Programming - Abstract Data Types Unit1: IntroductionSlide Number 1 Introduction Course: Object Oriented Programming Abstract Data.
AITI Lecture 20 Trees, Binary Search Trees Adapted from MIT Course 1.00 Spring 2003 Lecture 28 and Tutorial Note 10 (Teachers: Please do not erase the.
Non-static classes Part 2 1. Methods  like constructors, all non-static methods have an implicit parameter named this  for methods, this refers to the.
Copyright © 2002, Systems and Computer Engineering, Carleton University Hashtable.ppt * Object-Oriented Software Development Unit 8.
© A+ Computer Science - public Triangle() { setSides(0,0,0); } Constructors are similar to methods. Constructors set the properties.
Inheritance Building one object from another. Background Object-oriented programming is normally described has offering three capabilities Encapsulation:
27-Oct-15 Graphs and Hypergraphs. Graph definitions A directed graph consists of zero or more nodes and zero or more edges An edge connects an origin.
Object-Oriented Design CSC 212. Announcements This course is speeding up and we are starting new material. Please see me if you feel this is going too.
Overriding toString()
Mechanisms for Reuse CMPS OOP billed as technology that permits software to be constructed from general-purpose reusable components Two main mechanisms.
23-Dec-15 Graphs and Hypergraphs. Graph definitions A directed graph consists of zero or more nodes and zero or more edges An edge connects an origin.
CPSC 252 Hashing Page 1 Hashing We have already seen that we can search for a key item in an array using either linear or binary search. It would be better.
COMP 121 Week 8: Generic Collections. Objectives To understand type variables and how they are used in generic programming To be able to implement and.
(c) University of Washington06-1 CSC 143 Java Inheritance Tidbits.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Mutability SWE 332 Fall 2015 Paul Ammann. SWE 3322 Data Abstraction Operation Categories Creators Create objects of a data abstraction Producers Create.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 7: A Tale of Two Graphs (and.
Polymorphism and access control. RHS – SOC 2 What is polymorphism? In general: the ability of some concept to take on different forms In Java: the ability.
Lecture 3: Uninformed Search
CS240: Advanced Programming Concepts
Lecture 12 Inheritance.
Binary Search Trees One of the tree applications in Chapter 10 is binary search trees. In Chapter 10, binary search trees are used to implement bags.
Inference and search for the propositional satisfiability problem
Abstract Data Types II.
Chapter 11 Object-Oriented Design
Graphs and Hypergraphs
Binary Search Trees Why this is a useful data structure. Terminology
Variables as Remote Control
Graphs and Cycles.
Polymorphism 15-Nov-18.
Binary Search Trees One of the tree applications in Chapter 10 is binary search trees. In Chapter 10, binary search trees are used to implement bags.
Inheritance, Polymorphism, and Interfaces. Oh My
Polymorphism and access control
Polymorphism 28-Nov-18.
Testing and debugging A short interlude 2-Dec-18.
Equality, conclusion Based on material by Michael Ernst, University of Washington.
תירגול 9 אובייקטים.
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Lecture 7: A Tale of Two Graphs CS201j: Engineering Software
Graphs and Hypergraphs
Overriding methods from the Object class: equals, toString
Abstract Data Types 24-Feb-19.
Chapter 4 Unordered List.
Solving Exponential Equations
Notes from Week 5 CSE 115 Spring 2006 February 13, 15 & 17, 2006.
Polymorphism 15-Apr-19.
Testing and debugging A short interlude 17-Apr-19.
Polymorphism 21-Apr-19.
Review of Previous Lesson
Chapter 8 Class Inheritance and Interfaces
CS 112 Programming 2 Lecture 02 Abstract Classes & Interfaces (2)
Abstract Data Types II.
Early Midterm Some Study Reminders.
Presentation transcript:

Graph API (How I Did It) 1-Jan-19

APIs for ADTs Requirements of an API: Desirable properties of an API: The constructors and transformers must together be able to create all legal values of the ADT Or, at least, any needed by the applications that use it For a general use ADT, this means all legal values The accessors must be able to extract any data Desirable properties of an API: The API should be simple Convenience methods should be provided if: They are likely to be used often The user would expect them to be present (e.g. toString()) They simplify the use of the API more than they add complexity to it They provide serious gains in efficiency

My graph API I specified that: There would be three classes: Graph, Node, and Edge These classes would be based on the Plex class I suggested, but did not require, that these classes extend Plex, rather than just use it The Graph class would have a print() method My goals for my design were completeness and simplicity (in that order) I am not claiming that my design is the best possible I think it’s probably simpler than most of your designs

Graph methods Constructor Mutative transformers Accessors public Graph(Object value) Mutative transformers public void add(Node n) public void delete(Node node) public void delete(Edge edge) Accessors public Set<Node> nodes() @Override public String toString() public void print() public void dump() // debugging aid; prints Plexes

Node methods Constructor Mutative transformer Accessors public Node(Object value, Graph g) Mutative transformer public void delete() Accessors public Graph getGraph() public Set<Edge> getOutpointingEdges() public Set getInpointingEdges() @Override public String toString()

Edge methods Constructor Mutative transformer Accessors public Edge(Node fromNode, Object value, Node toNode, Graph g) Mutative transformer public void delete() Accessors public Graph getGraph() public Node getOrigin() public Node getDestination() @Override public String toString()

Where is...? Where’s the data? (Node names, edge labels, etc.) My classes all extend Plex, which has public Object value Where are the equals(Object obj) methods? I claim node equality means: Same node, same graph. In other words, == Similarly for edges Equality for graphs could mean graph isomorphism: There exist NodeNode and EdgeEdge mappings that make the graphs have identical structure To determine if there is an isomorphism, you must try all possible mappings In the worst case, this is intractable (exponential) Where are the hashCode() methods? The inherited hashCode methods are consistent with equals meaning == Where are the applicative transformers? I couldn’t see any use for them They’re easy enough for the user to write

Why do I have...? A deleteEdge(Edge edge) method in Graph? It’s just a convenience method Since I have deleteNode (which is necessary), it’s reasonable for the user to expect a corresponding deleteEdge method A getInpointingEdges() in Node? Most programs only use outpointing edges If the method is needed, it’s easy for me to provide, much much more complex for the user All those toString() methods? I think toString() is always a good idea—for debugging, if nothing else

The End