Visualising Java Data Structures as Graphs



Similar documents
DATA STRUCTURES USING C

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

3D Animation of Java Program Execution for Teaching Object Oriented Concepts

HAVING a good mental model of how a

Efficient Data Structures for Decision Diagrams

Project 4 DB A Simple database program

Java Software Structures

JustClust User Manual

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

CS170 Lab 11 Abstract Data Types & Objects

Collections in Java. Arrays. Iterators. Collections (also called containers) Has special language support. Iterator (i) Collection (i) Set (i),

Data Structure [Question Bank]

Technical paper review. Program visualization and explanation for novice C programmers by Matthew Heinsen Egan and Chris McDonald.

CompSci-61B, Data Structures Final Exam

Computing Concepts with Java Essentials

Introduction to Programming System Design. CSCI 455x (4 Units)

Java Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types

Data Structures in Java. Session 15 Instructor: Bert Huang

Semantic Analysis: Types and Type Checking

DE 6211 DISTANCE EDUCATION. M.Sc. (IT) DEGREE EXAMINATION, MAY PRINCIPLES OF INFORMATION TECHNOLOGY. (2002 onwards) PART A (10 3 = 30 marks)

Lecture 9. Semantic Analysis Scoping and Symbol Table

Data Structures and Data Manipulation

Lifting the Hood of the Computer: * Program Animation with the Teaching Machine

Introduction to Java

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays:

Fast track to HTML & CSS 101 (Web Design)

AP Computer Science Java Subset

Getting Started with the Internet Communications Engine

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

Glossary of Object Oriented Terms

Terms and Definitions for CMS Administrators, Architects, and Developers

Android Studio Application Development

10CS73:Web Programming

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push)

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt

AP Computer Science Java Mr. Clausen Program 9A, 9B

Introduction to Data Structures

Simply type the id# in the search mechanism of ACS Skills Online to access the learning assets outlined below.

10CS35: Data Structures Using C

Sample CSE8A midterm Multiple Choice (circle one)

Data Structures in the Java API

User Manual Microsoft Dynamics AX Add-on LabAX Label Printing

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition

Microsoft Access 2010 handout

Android Application Development Course Program

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

An Extensible Framework for Providing Dynamic Data Structure Visualizations in a Lightweight IDE

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

1 of 1 24/05/ :23 AM

The Java Collections Framework

Filtered Views for Microsoft Dynamics CRM

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.

9 CREATING REPORTS WITH REPORT WIZARD AND REPORT DESIGNER

Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A

Pivot Tables & Pivot Charts

Kaseya 2. Quick Start Guide. for VSA 6.3

Data Visualization. Prepared by Francisco Olivera, Ph.D., Srikanth Koka Department of Civil Engineering Texas A&M University February 2004

Software Development with UML and Java 2 SDJ I2, Spring 2010

Microsoft Office Excel 2007 Key Features. Office of Enterprise Development and Support Applications Support Group

CS506 Web Design and Development Solved Online Quiz No. 01

Map-like Wikipedia Visualization. Pang Cheong Iao. Master of Science in Software Engineering

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Auto-Generating Documentation & Source Code

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science

Also on the Performance tab, you will find a button labeled Resource Monitor. You can invoke Resource Monitor for additional analysis of the system.

Program to solve first and second degree equations

DataPA OpenAnalytics End User Training

Using EDA Databases: Milkyway & OpenAccess

PES Institute of Technology-BSC QUESTION BANK

How to make a Radar chart / spider chart

Introduction to Parallel Programming and MapReduce

Big O and Limits Abstract Data Types Data Structure Grand Tour.

Sample Questions Csci 1112 A. Bellaachia

Stacks. Data Structures and Data Types. Collections

COGNOS 8 Business Intelligence

University of Twente. A simulation of the Java Virtual Machine using graph grammars

Skills for Employment Investment Project (SEIP)

Using SQL Server Management Studio

ADP Workforce Now V3.0

Trace-Based and Sample-Based Profiling in Rational Application Developer

JAVA COLLECTIONS FRAMEWORK

CSE 2123 Collections: Sets and Iterators (Hash functions and Trees) Jeremy Morris

Tutorial Reference Manual. Java WireFusion 4.1

COMPUTER SCIENCE. Paper 1 (THEORY)

JavaFX Session Agenda

ImageNow Document Management Created on Friday, October 01, 2010

Parallelization: Binary Tree Traversal

MS WORD 2007 (PC) Macros and Track Changes Please note the latest Macintosh version of MS Word does not have Macros.

How to Develop Accessible Linux Applications

Parsing Technology and its role in Legacy Modernization. A Metaware White Paper

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

Microsoft Word Quick Reference Guide. Union Institute & University

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

Transcription:

Visualising Java Data Structures as Graphs John Hamer Department of Computer Science University of Auckland J.Hamer@cs.auckland.ac.nz John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 1/21

The Idea Student code calls the static method Dot.drawGraph(whatever) whatever can be any Java object. Dot.drawGraph traverses the object s fields using Java reflection outputs a GraphViz format graph description to a text file runs the GraphViz processor to produce a PNG (or EPS, etc.) picture Student views the sequence of pictures using a standard viewer John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 2/21

Example public static void main( String[] args ) { List xs = new LinkedList( ); for( int i = 0; i < 4; i++ ) { } } Dot.drawGraph( xs ); xs.add( new Integer(i+100) ); John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 3/21

Frame #1 LinkedList size: 0 header Entry element: null next previous John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 4/21

Frame #2 LinkedList size: 1 header Entry element: null next previous next previous Entry element: 100 John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 5/21

Frame #3 next LinkedList size: 2 header Entry element: null previous Entry element: 100 previous next next previous Entry element: 101 John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 6/21

Frame #4 LinkedList size: 3 header Entry element: null next previous Entry element: 100 next previous previous next Entry element: 101 next previous Entry element: 102 John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 7/21

Frame #4 coloured LinkedList size: 3 header Entry element: null next previous Entry element: 100 next previous previous next Entry element: 101 next previous Entry element: 102 Dot.Context ctx = Dot.defaultContext( ); ctx.setfieldattribute( "next", "color=blue" ); ctx.setfieldattribute( "previous", "color=red" ); John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 8/21

About GraphViz GraphViz is a widely used, freely available graph drawing program, developed at ATT; see www.graphviz.org Layout is completely automatic and (generally) æsthetically pleasing. Text input for nodes and edges, with optional attributes (colour, node shape, labels, fonts, etc.). Output to a variety of formats (PNG, EPS, SVG,... ) John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 9/21

Related work GraphViz Brocard Perl interface to GraphViz for visualising data structures; also regular expressions, grammars, XML, call graph, profiling,.... Visualisation North & Koutsofios visual debugger, vdbx Thomas Naps Visualiser class. Canned collection of visualisations: numeric arrays (bar, scattergram, data views), general arrays, stacks, queues, linked lists, binary trees, general trees, graphs, networks. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 10/21

Principles Students must be engaged in active learning; tools need to be simple to use; avoid distracting students from substantive course material; for instructors, minimise the effort required to integrate tools into the curriculum; software must be reliable. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 11/21

Features of our tool trivial to setup and easy to use (source < 600 lines); active learning students decide where to place the calls to drawgraph, what to elide; connects code with the Java data model; usable on any Java program; no specific programming conventions necessary; allows wrong data structures to be viewed (as well as correct ones); configuration allows broad and precise elision of detail; visualisations can be incorporated in reports, www pages, and presentations. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 12/21

Overcoming student misconceptions Java has a simple data model,? Strings are objects, but string constants look like primitive values. Assignment of objects is by reference, primitive types by value. Object arrays hold references, not values. 2-dimensional arrays are constructed from 1-d arrays (is it row or column order?) Static fields are not part of any object. Inheritance means objects are often not the same as their declared types. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 13/21

Visualising the Java data model HashMap size: 3 threshold: 8 loadfactor: 2.0 modcount: 3 table Arrays are displayed with elements juxtaposed. Values in primitive arrays are shown inline. Object arrays just contain links. 0 2 Primitive fields are shown inside the object s node. Entry key: three value: 3 hash: -741826716 Entry key: two value: 2 hash: -1000502134 Object fields are shown as labelled arcs. next Entry key: one value: 1 hash: -953555362 John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 14/21

Degrees of faithfulness Three different views of String Show the full internal state of String. Acknowledge String is an object, but hide the internal state. Pretend String is a primitive value (not an object). These views apply to any object, not just String. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 15/21

The Full Monty String x = "Hello"; String y = new String(x); Dot.drawGraph( new String[]{ x, y } ); String 0 offset: 0 count: 5 hash: 0 value String H e l l o 1 offset: 0 count: 5 hash: 0 value + Useful in explaining the memory consumption of substring operations, or as an example of a sharing data structure. Clutters the visualisation. Details are a distraction (e.g., explaining hash). John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 16/21

Hide the internal state Hello 0 1 Hello + Visualisation respects reference semantics. + More compact. Internal sharing is not shown. Can be used with any object, by calling the tostring method. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 17/21

Pretend it s primitive Hello Hello + Most compact. Visualisation contradicts reference semantics. Can be used with any object, by calling the tostring method. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 18/21

Limitations and future work GraphViz has limited support for node shapes, label placement,.... Graphs of, e.g., Java AWT components, can be immense. Drawing even a simple Button will bring in every interface component! Work in progress on integration with a debugger (Jacob Tseng). Extended a Java IDE debugger with a draw command. Graphs are updated at each breakpoint. Also, draw command extension to the BeanShell (an interactive Java interpreter), provided by a first-year student. More elision controls. Experimental features for dynamically selecting attributes (e.g., red nodes in a red-black tree are displayed in red). Interactive graphs select a node and expand or elide. John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 19/21

Summary and conclusions Light-weight, general purpose visualisation tool for Java. Useful in elucidating the Java data model, especially reference semantics. Less suitable for classical array data structures (c.f., Naps), or OOP (but see, e.g., UMLGraph http://www.spinellis.gr/sw/umlgraph/) Freely available from http://www.cs.auckland.ac.nz/~j-hamer John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 20/21

A view of an Arne Tree {0->"0",1->"1",10->"10",11->"11",12->"12",13->"13",14->"14",15->"15",16->"16",17->"17",18->"18",19->"19",2->"2",3->"3",4->"4",5->"5",6->"6",7->"7",8->"8",9->"9",a->"a",b->"b"} root key: 3 value: "3" level: 4 key: 11 value: "11" level: 3 key: 15 value: "15" level: 3 key: 7 value: "7" level: 3 key: 17 value: "17" level: 2 key: a value: "a" level: 2 key: 1 value: "1" level: 2 key: 13 value: "13" level: 2 key: 19 value: "19" level: 2 key: 5 value: "5" level: 2 key: 8 value: "8" key: 0 value: "0" key: 10 value: "10" key: 12 value: "12" key: 14 value: "14" key: 16 value: "16" key: 18 value: "18" key: 2 value: "2" key: 4 value: "4" key: 6 value: "6" key: 9 value: "9" key: b value: "b" key: b value: null level: -1 John Hamer, January 15, 2004 ACE 2004 Visualising Java Data Structures as Graphs p. 21/21