Sie sind auf Seite 1von 12

1

InfiniteGraph Manual

















2



Installation Steps:
Run the InfiniteGraph.exe file. Click next.

Figure 1: Installation step 1
Specify the installation directory. Click next.

Figure 2: Installation step 2


3


Select the installation options and click next.

Figure 3: Installation step 3
Select the components and settings you wish and click next.

Figure 4: Installation step 4
Your setup is done now! Start playing with InfiniteGraph!


4


Example code:
HelloGraph.java
package com.infinitegraph.samples.hellograph;
// Import all InfiniteGraph packages
import com.infinitegraph.*;

// Import SLF4J logging packages
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HelloGraph
{
public static void main(String[] args)
{
// Set up logging for the HelloGraph class
Logger logger = LoggerFactory.getLogger(HelloGraph.class);

// Create null transaction, null graph database instance
Transaction tx = null;
GraphDatabase helloGraphDB = null;

// Name for graph database
String graphDbName = "HelloGraph";

try
{
try
{
// Delete graph database if it already exists
GraphFactory.delete(graphDbName);
}
catch (StorageException sE)
{
logger.info(sE.getMessage());
}

// HINT: Add code to create graph database and its contents
// Create graph database
logger.info("> Creating graph database ...");
GraphFactory.create(graphDbName);

// Open graph database
logger.info("> Opening graph database ...");
helloGraphDB = GraphFactory.open(graphDbName);

// Begin transaction



5


logger.info("> Starting a read/write transaction ...");
tx = helloGraphDB.beginTransaction(AccessMode.READ_WRITE);

// Create two Person instances, adding them to the graph
// HINT: Add code to create vertices and edges here.
logger.info("> Creating Person vertices ...");
Person john = new Person("Shalini", "Hello ");
helloGraphDB.addVertex(john);
Person dana = new Person("Vinita", "Database!");
helloGraphDB.addVertex(dana);

// Create a Meeting instance
logger.info("> Creating Meeting edge ...");
Meeting meeting1 = new Meeting("NY", "Graph");

// Connect john to dana across the meeting1 edge
logger.info("> Connecting vertices ...");
john.addEdge(meeting1, dana, EdgeKind.BIDIRECTIONAL, (short) 0);

// Specify john as a named root for traversal
logger.info("> Naming a root vertex ...");
helloGraphDB.nameVertex("John", john);

// Commit to save your changes to the graph database
logger.info("> Committing changes ...");
tx.commit();
}

catch (ConfigurationException cE)
{
logger.warn("> Configuration Exception was thrown ... ");
logger.error(cE.getMessage());
}

finally
{
// If the transaction was not committed, complete
// will roll it back
if (tx != null)
tx.complete();
if (helloGraphDB != null)
{
helloGraphDB.close();
logger.info("> On Exit: Closed graph database");
}
}
}
}



6


// HINT: Add class definitions for Person and Meeting classes here.

class Person extends BaseVertex
{
private String name;
private String slogan;

public Person(String name, String slogan)
{
setName(name);
setSlogan(slogan);
}

public void setName(String name)
{
markModified();
this.name = name;
}

public String getName()
{
fetch();
return this.name;
}

public void setSlogan(String slogan)
{
markModified();
this.slogan = slogan;
}

@Override
public String toString()
{
fetch();
return this.slogan;
}
}

class Meeting extends BaseEdge
{
private String location;
private String message;

public Meeting(String location, String message)
{
setLocation(location);
setMessage(message);
}


7


public void setLocation(String location)
{
markModified();
this.location = location;
}

public String getLocation()
{
fetch();
return this.location;
}

public void setMessage(String message)
{
markModified();
this.message = message;
}

@Override
public String toString()
{
fetch();
return this.message;
}
}

Running the program:

Figure 5: Program execution

8


InfiniteGraph Visualiser:
InfiniteGraph Visualiser is automatically installed with the InfiniteGraph installation. With this
software, we can visualise the graph we have just created using the java code provided above.
To begin with visualising the graph, we have to first setup the connection. For this, specify the boot
file of your database and connect. Click on Finish button.

Figure 6: Visualiser 1












9


Here, Ill demonstrate some of the features of InfiniteGraph Visualiser. We can search a vertex by its
name by using the Search -> Named Vertex option as shown below.

Figure 7: Named vertex
Result of searching the named vertex John is shown in the following figure.

Figure 8: Result of named vertex 'John'


10


Under File -> Preferences, we can set vertex and edge label properties. Change the colors and icons.

Figure 9: Preferences
Below is the screenshot of a sub-graph.

Figure 10: Another subgraph



11


Clicking on any edge, shows the details of that edge below in the Properties box. The same applies
for vertices too.

Figure 11: Edge details
There are various options under the Navigation menu. One such option is Degrees of Separation. On
searching the named vertex Lisa, with 1 degree of separation we get the following result.

Figure 12: Degrees of Separation


12


When the degree of separation is 3, we get the following result.

Figure 13: Degrees of Separation
When the degree of separation is 5, we get the following result.

Figure 14: Degrees of Separation

Das könnte Ihnen auch gefallen