Posts tagged JUNG

JUNG Tutorial 3: Storing Node & Edge Data in a Hash Table

Introduction:

Welcome to the third JUNG Tutorial developed by Game2Learn, a member of UNC-Charlotte’s Games + Learning Laboratory. This time we will address the issue of Storing our edge and node data in a hash-table then using that table to access our specific data. There are two advantages of this approach, the first is decoupling, a software engineering term used to describe reducing the interconnection of two portions of a program. If two components are highly coupled that means they depend on each other, if they have low coupling it means that they are more like individual items and can stand alone. In object oriented programming, the goal is generally to have low coupling when possible in order to make our programs more modular.

In this tutorial by storing our data in a hash table, we can decouple our data from both our graph and our visual representation, the visualizationViewer. The second benefit is, you as a programmer, can have quicker access to your data because hash-table look ups have an O(1), read as Big O of 1. In addition the process of decoupling our data from the other components makes sense when we have some feature of our application which only needs to interact with the data of some node, and not the graph topology, like changing the color of one of our nodes in our example program here. As you will see in this tutorial, some component of our program does not require the entire graph in order to change the color field of our nodeData object, it just needs to access our hash-table which stores all of the data specific to each node.

Click here to download the Node & Edge Hash-Table Demo associated with this tutorial.

(more…)

JUNG Tutorial 2: Vertices with Shapes and Images

Introduction:

Welcome to the second JUNG Tutorial developed by Game2Learn, a member of UNC-Charlotte’s Games + Learning Laboratory. This time we will address the issue of Rendering Icons on Top of Shapes as a vertex in JUNG. So the problem is, you want to have a beautiful shaped vertices, but in addition you want to load some type of image as well inside, next to, or on top of that shape.

The desired goal can be seen below, we have square vertices with colors, we have icons, a O an X and a Game2Learn logo, and we want to print both. The solution we present here, in this tutorial, is to change the vertex render-er, which allows us to achieve the desired results of submitting both a vertexShapeTransformer and a vertexIconTransformer, and have both drawn, which is not possible with the default vertex renderer.

Check here to download the MultiVertexRenderer and associated demo.
(more…)

JUNG Tutorial 1: Loading Graphs with GraphML

Introduction:

Welcome to a new set of tutorials developed by Game2Learn, a member of UNC-Charlotte’s Games + Learning Laboratory. These tutorials are designed to how how to program using JUNG – the Java Universal Network/Graph Framework. In this tutorial we will learn about how to read a graph into JUNG using the GraphMLReader class which was incorporated into JUNG in version 2.0, and is a great addition to the JUNG framework. Although the JUNG examples do include a GraphMLReader example we hope this tutorial and related source code will be helpful. Additionally here we will make use of node and edge metadata, so that users can load in additional node and edge data that they want in their graph. Lastly, we will walk through what is happening step by step, in hopes to help those who are new to programming with JUNG.

In this lesson we will create the following:

The graph along with the console data will be the result of completing these tutorial.

We will read in a graphml file, attributes.graphml, which stores and set of nodes and edges and has weights on the edges and colors on the nodes as metadata. This is similar to the GraphML example provided by JUNG and we appreciate the work and efforts of those who have made JUNG possible.

Click here to download the Source code to the final project.

(more…)

Go to Top