A URL tagger sample application, and it’s source code is available here: http://wiki.infinitegraph.com/w/images/d/da/URLTagSample.zip
The URL Tagger Sample consists of two types of vertices represented by Url and Tag class objects. One edge class named UrlTagEdge is defined, which contains tag count tag date and user information.
The sample demonstrates the following things:
- Define edge and vertex classes by inheriting from BaseEdge and BaseVertex
- Create an InfiniteGraph Database by making use of a properties file
- Ingest data into the database, including Url and Tag vertices and set edges between them
- Examine the neighbors of each vertex.
- Navigate through the graph using a Navigator, and printing the results of the navigation via a NavigationResultHandler
To run the sample
- Copy and extract the files to the Samples directory of your installation
- Ensure the environment variables are set and the lockserver is running as specified in the installation readme. Specifically:
- PATH must include the bin directory of the InfiniteGraph installation. This is set automatically by the Windows InfiniteGraph installer
- If running on Linux/Solaris set the LD_LIBRARY_PATH or if on Mac set the DYLD_LIBRARY_PATH environment variable to include the lib directory of the InfiniteGraph installation.
- Start the lockserver by running oolockserver command line tool. On windows, the lockserver may already be started by a Windows service
- Run runSample.bat (on Windows) or runSample.sh (on Linux)
Output
[sourcecode language="powershell" gutter="false"]
C:\infinitegraph\Samples\URLTagSample>runSample.bat
C:\infinitegraph\Samples\URLTagSample>javac -cp "../../lib/oojava.jar;../../lib/InfiniteGraph-0.90.jar;." *.java
C:\infinitegraph\Samples\URLTagSample>java -cp "../../lib/oojava.jar;../../lib/InfiniteGraph-0.90.jar;." TagExample
Doing ingest
SM: adding new class to schema named Url as Url
SM: adding new class to schema named Tag as Tag
SM: adding new class to schema named UrlTagEdge as UrlTagEdge
Finished Ingest.
—————————
Tags of: http://cnn.com/
good
Information about edges between http://cnn.com/<->good
Tagged by: john 1 times.
Tagged by: jane 1 times.
Tags of: http://theonion.com/
funny
Information about edges between http://theonion.com/<->funny
Tagged by: john 1 times.
Tagged by: jane 1 times.
Tags of: http://xkcd.com/
funny
Information about edges between http://xkcd.com/<->funny
Tagged by: john 1 times.
Tagged by: jane 1 times.
—————————
Urls with tag: good
http://cnn.com/
Information about edge between good<->http://cnn.com/
Tagged by: john 1 times
Tagged by: jane 1 times
Urls with tag: funny
http://xkcd.com/
Information about edge between funny<->http://xkcd.com/
Tagged by: john 1 times
Tagged by: jane 1 times
http://theonion.com/
Information about edge between funny<->http://theonion.com/
Tagged by: john 1 times
Tagged by: jane 1 times
—————————
Doing Navigation
Found Start URL: http://theonion.com/
Found End URL: http://xkcd.com/
Showing All Paths between http://theonion.com/ and http://xkcd.com/
Navigation Result:
http://theonion.com/
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by john 1 times–>
funny
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by john 1 times–>
http://xkcd.com/
—————-
Navigation Result:
http://theonion.com/
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by john 1 times–>
funny
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by jane 1 times–>
http://xkcd.com/
—————-
Navigation Result:
http://theonion.com/
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by jane 1 times–>
funny
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by john 1 times–>
http://xkcd.com/
—————-
Navigation Result:
http://theonion.com/
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by jane 1 times–>
funny
<–Tagged Wed Jul 14 13:39:18 PDT 2010 by jane 1 times–>
http://xkcd.com/
—————-
[/sourcecode]
