ORMS Today
June 1999

Graph Editor Toolkit 3.1


Programming toolkit provides a set of objects, properties and methods to build custom applications that use diagrams or graphs

By Peter Varhol

Despite the ready availability of increasingly powerful and easy-to-use simulation tools, many OR professionals still find the need to code their own applications. Fortunately, development tools such as Visual Basic (VB) are also powerful and easy to use, although they are less immediately suited to simulation and modeling problems.

In the Microsoft Windows environment, ActiveX controls can bridge the gap between a powerful but raw development tool and a useful simulation and modeling environment. An ActiveX control can be integrated into the development environment as an object and used the same way as standard objects such as list boxes and command buttons.

All VB objects (technically, they are classes, but don't have all of the characteristics of pure object-oriented classes) have properties, or characteristics describing them that can be changed before or during program execution. For example, the VB Command Button has a unique name, a label, a tag to designate it as enabled or not, and a size, to name a few.

The VB environment is designed to identify and respond to events, which are actions from the user, from other parts of a program, or from other programs. An event may be a mouse click, a menu selection, the movement of the pointer, or any of dozens of things that can be identified and tracked by the system.

VB objects also have methods, or functions that are an inherent part of the object and are used to manipulate the object in response to events. Most of the methods available with objects are simple to understand and use, making it possible to write useful programs with little or no formal programming background.

My colleagues and I do a good deal of network modeling, design and implementation, both for LAN and LAN/WAN combinations. Most of the time we're not able to design ideal architectures because of legacy considerations, cost limitations or other barriers. So performance, somewhat predictable in the lab with the idealized network architecture, becomes impossible to assess for real-world scenarios. Successfully modeling existing network architectures is becoming a prerequisite for introducing new computing concepts into an organization.

A Modeling Framework


Tom Sawyer Software's Graph Editor Toolkit is an ActiveX control that lets the user define, diagram and organize graphs using formal organizational methods. It can be added as a component to Visual Basic, Visual C++, Delphi or any other Windows-based development environment that accepts ActiveX controls.

Graph Editor Toolkit isn't an end-user product for the consumer, such as Visio; rather, it's a programming toolkit. It provides a set of objects, properties and methods that build a foundation for custom applications that use diagrams (also called "graphs" by those with mathematical backgrounds) consisting of potentially very large numbers of objects. As such, don't expect to effectively use the Graph Editor Toolkit unless you're already comfortable with Visual Basic or other software development environments that support ActiveX controls, and are prepared to put in some time to build your own modeling application.

The Graph Editor Toolkit provides a foundation for creating sophisticated graph applications through a strong focus on formal graphs and comprehensive, object-oriented software architecture. It provides a set of constructs for programming graph displays, and lets programmers use their imagination to incorporate simulation routines that make use of its node-and-edge graph structure.

The Graph Editor Toolkit is made up of three basic object types: the Graph Editor control object, Graph objects and Geometry objects. The control object is the user interface for all of the available graphs and other objects, and the only object directly created by the user.

The Graph object contains information about graphs, including their components and relationships. They include the node, edge, label and navigation objects, which are the building blocks of graph displays. Geometry objects contain descriptions of the size, shape and connections of individual nodes and edges in a graph.

While the objects themselves exist as a part of the ActiveX control and their source code is outside of the development environment, the object interfaces, properties and methods are open and extensible in the Visual Basic environment. Instead of trying to figure out how an interface works through trial and error, you have the event handlers and methods open and available to you. This makes the Graph Editor Toolkit a lot easier to write programs to than a traditional applications programming interface.

Building a Modeling Environment


One of the significant problems my colleagues and I face is how to determine performance constraints in thin client environments. Because our focus is on server-based thin client computing, we're just as interested in looking at resource utilization and constraints on server systems as we are on full network solutions.

This focus provides a logical approach to modeling thin client networks. It makes more sense to model critical resources within individual servers, and to build full networks hierarchically from these resources. So memory, CPU, network bandwidth and disk bandwidth can all be their own objects, with properties representing capacities and bandwidth. Event handlers can be used to provide a method of interacting between them. And these fundamental objects can be hierarchically arranged to provide for more complex interactions.

To do this in Visual Basic isn't conceptually very difficult. Thanks to its event-driven architecture, it's possible to take objects and assign event handlers that reproduce the necessary discrete event behaviors. The existing Timer control provides a means of controlling events based on the passage of time.

What are lacking in VB are the objects, properties and event handlers for displaying the model and its output visually. This includes specialized operations such as creating and viewing graphs, to support the modeling processes. And that's a shame, because VB is easily learned and provides powerful facilities for creating both static and dynamic models. You can create new objects and methods for visual display and manipulation using ActiveX with C++, Java or VB itself (VB has supported the creation of ActiveX controls within the language since version 5), but this represents a great deal of work that is probably unrelated to your modeling activities.

It's been many years since I've been a full-time programmer, and languages such as C or C++ are too demanding for my occasional programming needs. Visual Basic is simple and easily understandable, making it possible for me to set aside a project for a week or more and still return to it without going through a steep learning curve. (Java, a simple and elegant object-oriented language, also possesses this characteristic; Tom Sawyer Software also sells a 100 percent pure Java version of the Graph Editor Toolkit.)

The Graph Editor Toolkit takes much of the low-level effort out of creating, manipulating and formatting graphs. It does so by providing a set of constructs TSGraph, TSNode, TSEdge and about 30 other objects that programmers tap for creating and laying out nodes, edges and graph properties. By calling the methods associated with these graph objects, you can change characteristics of nodes, create and break links, and move graphs around on the screen. In my own design of a network-modeling environment, these features represent the necessary but mundane work of developing the graphical displays that I didn't want to write myself.

It takes careful thought and a well-conceived design to even begin to build a modeling environment based on the Graph Editor Toolkit. Unless you've been giving a lot of detailed thought and are extremely proficient with Visual Basic, don't expect to implement your modeling application over a weekend. In all likelihood, you'll spend that weekend simply trying to envision just what parts the toolkit provides for your own application. I took over a month to think through the design of my network modeling software and to begin an implementation using the Graph Editor Toolkit.

The best way to get started is to imagine the Graph Editor Toolkit constructs as building blocks, and make some decisions on what you're going to build with them. Tom Sawyer Software provides an interesting example application in the way of a fully implemented computer network layout tool, complete with large and sophisticated network designs.

If you let this example guide your own application design decisions, however, you're probably doing yourself a disservice. This application is more like a Visio than a modeling environment; it lets you create pretty pictures of networks, viewing them in different arrangements, and moving parts of the diagram around for different perspectives. You probably want an application that does more than that.

But that doesn't mean that you can't make use of the hundreds of lines of Visual Basic source code provided by this example. Tom Sawyer's Graph Editor Toolkit builds palettes, event handlers, help files and other facilities into this sample application that can be invaluable in cutting down the amount of drudge work needed to create your application. In my case, much of my work in making my modeling environment visual was already done by the Tom Sawyer examples.

But despite the development possibilities, it's important to remember that the name of the product is the Graph Editor Toolkit. Its inherent facilities provide a sophisticated way of formatting and editing graphs so that the information developed by the application can be more easily visualized. Graphical layout facilities have value in performing work you'd probably rather not have to do, and that's where the Graph Editor Toolkit delivers most of its value. It doesn't design and build your application for you, however.

A graph application can offer views that provide new perspectives on a particular class of problems. My network simulations are an obvious case in point. I can write the underlying discrete event algorithms, generate the random numbers, launch the program and collect the results, without ever having to see a diagram of the model.

But visualizing the network seems to provide modelers with a better understanding of how the network works, and how it can be better measured and modified. Thanks to the properties associated with node and edge objects in a graph, I can change a visual characteristic, such as color or line thickness, of an object during model execution to designate a transaction residing in that object.

I can also provide text output of things such as queue length, server utilization and transactions processed. This would be easy to do programmatically using a text box in Visual Basic, but it requires writing code to tell it what data to display, and where to get it from, every time I want to use it. Instead, by embedding a text box in a subclass of TSNode, I can tell it to gather network statistics from any object on the other end of a TSEdge, so I only have to write the code once. All the end user has to do is connect it to a network object, without worrying about the underlying code.

Getting Down to Business


Tom Sawyer Software's Graph Editor Toolkit installs on a Windows NT or Windows 95/98 computer from a single CD-ROM, and requires about 10 MB of disk space. Once installed, it creates an entry on the Start menu with VB and C++ examples, online documentation and licensing instructions. The examples are worth examining, but they don't provide the primary means of using the toolkit.

Instead, you open a VB workspace (the documentation suggests using the Standard .EXE alternative) and add the Graph Editor Toolkit as a Component under the Project menu. When you do, the Layout control appears on the control bar along with the standard VB controls. Clicking on the Layout control and placing it on a form displays a basic Layout window of object type TSGraphEditorControl. In this window, you access all of the other calls.

You can modify the instance of TSGraphEditorControl through properties such as defaultNodeName, edgeViewDescription, mode and showMessageBox. The software also provides its own set of properties; for example, you can change the mouse pointer by changing the following properties of the control:
Mode: TS_ADD_NODE_MODE,
      nodeViewDescription: TSEShapeNodeView
defaultNodeName: Untitled
Control Name: editor
To create a simple graph,
Private Sub Form_Load()
Dim fromNode As TomSawyer.TSNode
Dim toNode As TomSawyer.TSNode
Set fromNode = editor.addNode(100,100,
      "TSEPictureTextView 110", True, False)
Set toNode = editor.addNode(-100, -100,
      "TSEPictureTextView 110", True, False)
Editor.addEdge fromNode, toNode,
      "TSEPropertyEdgeView", True, False
End Sub
Figure 1 shows the simple graph produced by this VB code. One attraction of the Graph Editor Toolkit is the ability to keep track of nodes and edges attached to them. I use this by querying connected nodes to be able to send signals from one to another. The signals don't travel along the edges; rather, the edges provide a user mechanism for establishing a relationship between nodes. When a queue block is connected with an edge to a server block, the program is able to send a transaction to the correct server. Figure 2 shows a more complex diagramming application built using the Graph Editor Toolkit that enables an end user to build and examine computer network designs. As diagrams grow in size and complexity, the Graph Editor Toolkit has an added benefit because it uses Tom Sawyer's graph layout algorithms to automatically arrange nodes and edges so the diagram is presented clearly.


Figure 1

Figure 1: A simple graph produced by VB code.

Figure 2

Figure 2: A more complex diagramming application built using the Graph Editor Toolkit.

The Bottom Line


I began my evaluation with the Graph Editor Toolkit with Version 3.0, which worked with Visual Basic 5.0 but not the recently introduced VB 6.0. I was able to finish with a beta copy of Graph Editor Toolkit 3.1, which did work with VB 6.0. That appeared to be the significant difference between the two versions from a functional point of view.

Tom Sawyer Software's Graph Editor Toolkit isn't specifically for everyone doing system modeling and simulation. If existing commercial simulation software packages are already meeting your needs, it may be better to not consider building your own. And if your concept of modeling doesn't include writing your own tools, then you should consider looking elsewhere.

But for many, the journey is at least half the reward. In my own modeling experiences, I've found that by writing my own tools, I not only understand the problem space better, but also know how to immediately apply the tools to an individual problem. It makes me more productive and better able to produce an acceptable model.

The Graph Editor Toolkit is intended to be a general programmer's toolkit. It can be integrated as an ActiveX control into existing programming environments to produce nice, organized graphs. By working with Visual Basic, it is accessible to the several million people who at least occasionally program in that language. In effect, it delivers three distinct advantages:
  1. For a modeling application (whether already existing in VB or in development) that lets users draw or manipulate graphs, the Graph Editor Toolkit organizes and displays graphs that were probably created haphazardly or over time. It allows users to lay out models according to their own logic, and format them to make them neat and understandable.

  2. It provides a neat and well-documented way to take care of some of the programmatic "housekeeping" tasks associated with creating and maintaining graphs, including handling connections between nodes and visual properties of graph objects.

  3. It provides a foundation for building applications that rely on visualizing the relationships between objects, and the overall view of a network-like diagram. With the Graph Editor Toolkit, you have a good idea of what you get. I didn't find any bugs or unexpected behavior in calling methods or changing properties. The most interesting aspect of working with the Graph Editor Toolkit is that the more I worked with it, the more I discovered what it could do for me. The listing of objects, properties and methods doesn't mean a lot until you need to use them in actual programming.


The documentation consists of two bound books, a user's guide and a reference manual. These are also available online for convenient access. They contain a large amount of information and include code examples throughout the text. Often it's best to learn by doing, and your best bet is to read just enough to get you started (the Visual Basic tutorial and the first few chapters in the user's guide should be enough), and use the rest of the documentation as a spot reference.

If you're interested in developing your own modeling application, the Graph Editor Toolkit can help you develop the graphical editor and diagram management portion of your application. If you already have a text-based modeling application, or if you're willing to invest the time and effort to write your own, the Graph Editor Toolkit can provide a sophisticated set of operations for programming a user interface for visually manipulating and laying out your modeling components.

Company Information
Tom Sawyer Software
804 Hearst Avenue
Berkeley, CA 94710
(510) 848-0853
fax: (510) 848-0854
Web: http://www.tomsawyer.com





Peter Varhol is lab manager for The Taylor Center for Thin Client Computing in Bedford, N.H., developers of network architectures and large-scale deployment strategies.





  • Table of Contents

  • OR/MS Today Home Page


    OR/MS Today copyright 1999 by the Institute for Operations Research and the Management Sciences. All rights reserved.


    Lionheart Publishing, Inc.
    2555 Cumberland Parkway, Suite 299, Atlanta, GA 30339 USA
    Phone: 770-431-0867 | Fax: 770-432-6969
    E-mail: lpi@lionhrtpub.com
    URL: http://www.lionhrtpub.com


    Web Site Copyright 1999 by Lionheart Publishing, Inc. All rights reserved.