Carleton University School of Computer Science Comp 5901 Directed Studies
Total Page:16
File Type:pdf, Size:1020Kb
Carleton University School of Computer Science Comp 5901 Directed Studies JJGGrraapphhEEdd –– AA JJaavvaa GGrraapphh EEddiittoorr aanndd GGrraapphh DDrraawwiinngg FFrraammeewwoorrkk Author: Jon Harris Submitted: April 28, 2004 Submitted To: Professor Pat Morin Table of Contents 1. Introduction..................................................................................................................... 4 2. Framework ...................................................................................................................... 4 2.1 Graph Structure......................................................................................................... 4 2.1.1 Graph.................................................................................................................. 4 2.1.1.1 Interface for editing..................................................................................... 5 2.1.1.2 Drawing....................................................................................................... 6 2.1.1.3 Log Entries.................................................................................................. 7 2.1.1.4 Undo / Redo Mementos .............................................................................. 7 2.1.1.5 Copies ......................................................................................................... 7 2.1.2 Node................................................................................................................... 8 2.1.3 Edge ................................................................................................................... 8 2.1.4 Node and Edge Extenders................................................................................ 10 2.1.5 Graph Files....................................................................................................... 10 2.2 User Interface.......................................................................................................... 11 2.2.1 Menu and Toolbar............................................................................................ 11 2.2.2 Graph Editor..................................................................................................... 13 2.2.2.1 Graph Editor Modes.................................................................................. 14 2.2.2.1.1 Edit Mode........................................................................................... 14 2.2.2.1.1 Grid Mode.......................................................................................... 16 2.2.2.1.1 Move, Resize and Rotate Modes ....................................................... 16 2.2.2.2 Graph Editor Dialogs ................................................................................ 17 2.2.2.3 Graph Editor Info Window ....................................................................... 17 2.2.2.4 Graph Editor Log Window ....................................................................... 17 2.2.3 Graph Controller .............................................................................................. 18 2.2.3.1 Graph Editor Preferences Window ........................................................... 18 2.2.3.2 Graph Editor Help Window...................................................................... 19 3 Data Structures............................................................................................................... 19 3.1 Doubly Linked List................................................................................................. 19 3.2 Queue ...................................................................................................................... 19 3.3 Binary Heap ............................................................................................................ 20 3.4 Node Split Tree (KD-Tree)..................................................................................... 20 3.5 PQ / PQD Tree........................................................................................................ 21 4 Operations (Algorithms) ................................................................................................ 21 4.1 Adding a New Operation to JGraphEd ................................................................... 22 4.2 Existing Operations in JGraphEd............................................................................ 23 4.2.1 Create Random Graph...................................................................................... 23 4.2.2 Depth First Search............................................................................................ 23 4.2.3 Connectivity..................................................................................................... 23 4.2.4 Biconnectivity.................................................................................................. 24 4.2.5 Make Maximal Planar...................................................................................... 26 4.2.6 ST Numbering.................................................................................................. 27 4.2.7 Planarity Testing .............................................................................................. 29 4.2.8 Embedding ....................................................................................................... 30 4.2.9 Canonical Ordering.......................................................................................... 32 4.2.10 Normal Labeling ............................................................................................ 34 4.2.11 Schnyder Straight Line Grid Embedding....................................................... 36 4.2.12 Tree ................................................................................................................ 38 4.2.13 Chan Tree....................................................................................................... 39 4.2.14 Dijkstra’s Shortest Path.................................................................................. 42 4.2.15 Minimal Spanning Tree ................................................................................. 43 5 Conclusion ..................................................................................................................... 43 6 References...................................................................................................................... 44 Table of Figures Figure 1 A sample graph being edited with JGraphEd....................................................... 6 Figure 2 Half-Edge Structure.............................................................................................. 9 Figure 3 Bézier Curve and Control Points........................................................................ 10 Figure 4 Snapshot of JGraphEd's menu and toolbar, with button chooser expanded/showing.............................................................................................. 12 Figure 5 Illustration of Biconnected Sub-Graphs and Separator Nodes........................... 24 Figure 6 Illustration of Make Biconnected Operation ...................................................... 26 Figure 7 Illustration of Make Maximal Planar Operation ................................................ 27 Figure 8 Illustration of an ST-Numbered Graph............................................................... 28 Figure 9 Illustration of Planar, and Non-Planar Graphs ................................................... 29 Figure 10 Illustration of the Embedding Operation.......................................................... 31 Figure 11 Illustration of the requirements of a Canonical Ordering................................. 32 Figure 12 Illustration of a Canonical Ordered Graph ....................................................... 33 Figure 13 Illustration of a Normal Labeled Graph ........................................................... 34 Figure 14 Illustration of the order of edges around a Normal Labeled Node................... 35 Figure 15 Illustration of the Realizers of a Graph ............................................................ 35 Figure 16 Illustration of the Edge Contraction Process.................................................... 36 Figure 17 Illustration of the 3 Regions of a Node (shown in white) ................................ 37 Figure 18 Illustrations of a Schnyder Straight Line Grid Embedding (9 nodes, 7x7 grid)38 Figure 19 Illustrations of (regular) Left and Right Rules for Chan's Algorithm .............. 40 Figure 20 Illustrations of Extended Left and Right Rules for Chan's Algorithm............. 41 1 Introduction This document describes the design and implementation of JGraphEd, a Java Graph Editing application and Graph Drawing framework. JGraphEd was designed to allow users to easily create graphs step by step by adding or removing, or modifying nodes or edges. JGraphEd is modular by design and a variety of standalone and interdependent algorithms have been provided for manipulating or visualizing graphs. JGraphEd was also designed with extensibility in mind, in order to allow developers to quickly and painlessly add their own algorithms to the included library. Section 2 of this document describes the framework of JGraphEd. This includes classes which are responsible for representing graphs and the commands that can be used upon them. The framework documentation also describes the user interface of JGraphEd, and may be used as a user’s guide.