|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgraph_gen_utils.NeoFromFile
public class NeoFromFile
Provides easy means of creating a Neo4j instance from various graph file formats, loading a Neo4j instance into an in-memory graph, calculating various graph metrics and writing them to file.
Nested Class Summary | |
---|---|
static class |
NeoFromFile.ChacoType
|
Constructor Summary | |
---|---|
NeoFromFile()
|
Method Summary | |
---|---|
static void |
appendMetricsCSV(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String metricsPath,
java.lang.Long timeStep)
Calculates graph metrics for the current Neo4j instance and appends the results to a comma separated metrics (.met) file. |
static void |
applyPtnToNeo(org.neo4j.graphdb.GraphDatabaseService transNeo,
graph_gen_utils.partitioner.Partitioner partitioner)
Allocates nodes of a Neo4j instance to clusters/partitions. |
static void |
applyPtnToNeo(org.neo4j.graphdb.GraphDatabaseService transNeo,
graph_gen_utils.partitioner.Partitioner partitioner,
java.util.Map<java.lang.String,java.lang.Object> props)
Allocates nodes of a Neo4j instance to clusters/partitions. |
static void |
main(java.lang.String[] args)
|
static graph_gen_utils.memory_graph.MemGraph |
readMemGraph(org.neo4j.graphdb.GraphDatabaseService transNeo)
Loads the current Neo4j instance into an in-memory graph. |
static graph_gen_utils.memory_graph.MemGraph |
readMemGraph(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.util.Set<java.lang.String> nodeProps,
java.util.Set<java.lang.String> relProps)
|
static void |
removeDuplicateRelationships(org.neo4j.graphdb.GraphDatabaseService transNeo,
org.neo4j.graphdb.Direction direction)
Deletes duplicate Relationship s (all but one Relationship
between any two Node s). |
static void |
removeOrphanNodes(org.neo4j.graphdb.GraphDatabaseService transNeo)
Deletes all Node s that do not have at least one
Relationship from the Neo4j instance. |
static void |
removeRelationshipsByType(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.util.HashSet<java.lang.String> relTypes)
Deletes all Relationship s of the specified
RelationshipType values (as given by the String values in
relTypes parameter) from the Neo4j instance. |
static void |
writeChaco(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String chacoPath,
NeoFromFile.ChacoType chacoType)
Creates a Chaco file and populates it with the adjacency list representation of the current Neo4j instance. |
static void |
writeChacoAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String chacoPath,
NeoFromFile.ChacoType chacoType,
java.lang.String ptnPath)
Creates a Chaco (.graph) file and partition (.ptn) files, populates them with the representation of the current Neo4j instance. |
static void |
writeGMLBasic(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String gmlPath)
Creates a GML (.gml) file and populates it with the representation of the current Neo4j instance. |
static void |
writeGMLFull(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String gmlPath)
Creates a GML (.gml) file and populates it with the representation of the current Neo4j instance. |
static void |
writeMetrics(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String metricsPath)
Calculates graph metrics for the current Neo4j instance, creates a metrics (.met) file and populates it. |
static void |
writeMetricsCSV(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String metricsPath)
Calculates graph metrics for the current Neo4j instance, creates a comma separated metrics (.met) file and populates it. |
static void |
writeNeoFromChaco(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String graphPath)
Creates a Neo4j instance and populates it from the contents of a Chaco (.graph) file. |
static void |
writeNeoFromChacoAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String graphPath,
graph_gen_utils.partitioner.Partitioner partitioner)
Creates a Neo4j instance, populates it from the contents of a Chaco (.graph) file, then allocates Node s to partitions/clusters. |
static void |
writeNeoFromChacoAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String graphPath,
java.lang.String ptnPath)
Creates a Neo4j instance, populates it from the contents of a Chaco (.graph) file, then allocates Node s to partitions/clusters. |
static void |
writeNeoFromChacoAndPtnBatch(java.lang.String dbDir,
java.lang.String graphPath,
graph_gen_utils.partitioner.Partitioner partitioner)
Creates a Neo4j instance using the BatchInserter , populates it
from the contents of a Chaco (.graph) file, then allocates Node s
to partitions/clusters. |
static void |
writeNeoFromGML(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String gmlPath)
Creates a Neo4j instance and populates it from the contents of a GML (.gml) file. |
static void |
writeNeoFromGMLAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String gmlPath,
graph_gen_utils.partitioner.Partitioner partitioner)
Creates a Neo4j instance and populates it from the contents of a GML (.gml) file, then allocates Node s to partitions/clusters. |
static void |
writeNeoFromTopology(org.neo4j.graphdb.GraphDatabaseService transNeo,
graph_gen_utils.reader.topology.GraphTopology topology)
Creates a Neo4j instance and populates it according to a generated graph topology. |
static void |
writeNeoFromTopologyAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo,
graph_gen_utils.reader.topology.GraphTopology topology,
graph_gen_utils.partitioner.Partitioner partitioner)
Creates a Neo4j instance, populates it according to a generated graph topology, then allocates Node s to partitions/clusters. |
static void |
writeNeoFromTwitterDataset(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String twitterPath)
Creates a Neo4j instance and populates it from the contents of a dataset with a proprietry binary file format, which contains user follows/following connectivity data from Twitter. |
static void |
writeNeoFromTwitterDatasetAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo,
java.lang.String twitterPath,
graph_gen_utils.partitioner.Partitioner partitioner)
Creates a Neo4j instance and populates it from the contents of a dataset with a proprietry binary file format, which contains user follows/following connectivity data from Twitter. |
static void |
writeNeoFromTwitterDatasetBatch(java.lang.String dbDir,
java.lang.String twitterPath)
Creates a Neo4j instance using the BatchInserter , then populates
it from the contents of a dataset with a proprietry binary file format,
which contains user follows/following connectivity data from Twitter. |
static p_graph_service.PGraphDatabaseService |
writePNeoFromNeo(java.lang.String pdbPath,
org.neo4j.graphdb.GraphDatabaseService transNeo)
Moved from neo4j_partitioned_api. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NeoFromFile()
Method Detail |
---|
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public static p_graph_service.PGraphDatabaseService writePNeoFromNeo(java.lang.String pdbPath, org.neo4j.graphdb.GraphDatabaseService transNeo)
GraphDatabaseService
as input, creates a new partitioned version
PGraphDatabaseService
in the specified directory, then copies all
data from the input instance into the new instance. Node
s must
have a Consts.COLOR
attribute as this is used to decide which
partition each Node
is stored in.
transNeo
- GraphDatabaseService
representing the regular Neo4j
instancepdbPath
- String
specifying the directory where partitioned
Neo4j instance should be created
PGraphDatabaseService
public static void applyPtnToNeo(org.neo4j.graphdb.GraphDatabaseService transNeo, graph_gen_utils.partitioner.Partitioner partitioner)
Partitioner
parameter. Method writes
Consts.COLOR
property to all nodes of an existing Neo4j instance.
Consts.NODE_LID
, Consts.NODE_GID
, Consts.LATITUDE
, Consts.LONGITUDE
properties are also written to all nodes.
transNeo
- GraphDatabaseService
representing a Neo4j instancepartitioner
- implementation of Partitioner
that defines
cluster/partition allocation schemepublic static void applyPtnToNeo(org.neo4j.graphdb.GraphDatabaseService transNeo, graph_gen_utils.partitioner.Partitioner partitioner, java.util.Map<java.lang.String,java.lang.Object> props)
Partitioner
parameter. Method writes
Consts.COLOR
property to all nodes of an existing Neo4j instance.
Consts.NODE_GID
property is also written to all Node
s.
User may also specify additional properties (e.g. Consts.LATITUDE
) and default values. These will be written to all Node
s.
transNeo
- GraphDatabaseService
representing a Neo4j instancepartitioner
- implementation of Partitioner
that defines
cluster/partition allocation schemeprops
- Additional propertiespublic static void writeNeoFromTopology(org.neo4j.graphdb.GraphDatabaseService transNeo, graph_gen_utils.reader.topology.GraphTopology topology)
GraphTopologyRandom
) and fully connected (
GraphTopologyFullyConnected
) graphs.
transNeo
- GraphDatabaseService
representing a Neo4j instancetopology
- instance of GraphTopology
the defines generated
topologypublic static void writeNeoFromTopologyAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo, graph_gen_utils.reader.topology.GraphTopology topology, graph_gen_utils.partitioner.Partitioner partitioner)
Node
s to partitions/clusters. Examples
of possible topologies are random (GraphTopologyRandom
) and fully
connected (GraphTopologyFullyConnected
) graphs. Allocation scheme
is defined by the Partitioner
parameter.
transNeo
- GraphDatabaseService
representing a Neo4j instancetopology
- instance of GraphTopology
the defines generated
topologypartitioner
- implementation of Partitioner
that defines
cluster/partition allocation schemepublic static void writeNeoFromChaco(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String graphPath)
transNeo
- GraphDatabaseService
representing a Neo4j instancegraphPath
- String
representing path to .graph filepublic static void writeNeoFromChacoAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String graphPath, java.lang.String ptnPath)
Node
s to partitions/clusters. Chaco
files are basically persistent adjacency lists. Partition/cluster
allocation is defined by the contents of a .ptn file. This method is only
included for convenience/ease of use.
writeNeoFromChacoAndPtn(GraphDatabaseService, String, Partitioner)
can achieve the same thing.
transNeo
- GraphDatabaseService
representing a Neo4j instancegraphPath
- String
representing path to .graph fileptnPath
- String
representing path to .ptn filepublic static void writeNeoFromChacoAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String graphPath, graph_gen_utils.partitioner.Partitioner partitioner)
Node
s to partitions/clusters. Chaco
files are basically persistent adjacency lists. Allocation scheme is
defined by the Partitioner
parameter.
transNeo
- GraphDatabaseService
representing a Neo4j instancegraphPath
- String
representing path to .graph filepartitioner
- implementation of Partitioner
that defines
cluster/partition allocation schemepublic static void writeNeoFromChacoAndPtnBatch(java.lang.String dbDir, java.lang.String graphPath, graph_gen_utils.partitioner.Partitioner partitioner)
BatchInserter
, populates it
from the contents of a Chaco (.graph) file, then allocates Node
s
to partitions/clusters. Chaco files are basically persistent adjacency
lists. Allocation scheme is defined by the Partitioner
parameter.
dbDir
- String
representing the path to a Neo4j instancegraphPath
- String
representing path to .graph filepartitioner
- implementation of Partitioner
that defines
cluster/partition allocation schemepublic static void writeNeoFromGML(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String gmlPath)
transNeo
- GraphDatabaseService
representing a Neo4j instancegmlPath
- String
representing path to .gml filepublic static void writeNeoFromGMLAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String gmlPath, graph_gen_utils.partitioner.Partitioner partitioner)
Node
s to partitions/clusters. GML
files are basically an ASCII version of the GraphML format. Allocation
scheme is defined by the Partitioner
parameter.
transNeo
- GraphDatabaseService
representing a Neo4j instancegmlPath
- String
representing path to .gml filepartitioner
- implementation of Partitioner
that defines
cluster/partition allocation schemepublic static void writeNeoFromTwitterDataset(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String twitterPath)
transNeo
- GraphDatabaseService
representing a Neo4j instancetwitterPath
- String
representing path to Twitter datasetpublic static void writeNeoFromTwitterDatasetAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String twitterPath, graph_gen_utils.partitioner.Partitioner partitioner)
Node
s to
partitions/clusters. Allocation scheme is defined by the
Partitioner
parameter.
transNeo
- GraphDatabaseService
representing a Neo4j instancetwitterPath
- String
representing path to Twitter datasetpartitioner
- implementation of Partitioner
that defines
cluster/partition allocation schemepublic static void writeNeoFromTwitterDatasetBatch(java.lang.String dbDir, java.lang.String twitterPath)
BatchInserter
, then populates
it from the contents of a dataset with a proprietry binary file format,
which contains user follows/following connectivity data from Twitter. The
file was obtained by crawling Twitter for 300 hours.
dbDir
- String
representing the path to a Neo4j instancetwitterPath
- String
representing path to Twitter datasetpublic static void writeChaco(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String chacoPath, NeoFromFile.ChacoType chacoType)
transNeo
- GraphDatabaseService
representing a Neo4j instancechacoPath
- String
representing path to .graph filechacoType
- NeoFromFile.ChacoType
specifies whether node and/or edge weights
are written to the chaco filepublic static void writeChacoAndPtn(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String chacoPath, NeoFromFile.ChacoType chacoType, java.lang.String ptnPath)
transNeo
- GraphDatabaseService
representing a Neo4j instancechacoPath
- String
representing path to .graph filechacoType
- NeoFromFile.ChacoType
specifies whether node and/or edge weights
are written to the chaco fileptnPath
- String
representing path to .ptn filepublic static void writeGMLFull(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String gmlPath)
Node
and Relationship
properties are written to the GML file.
transNeo
- GraphDatabaseService
representing a Neo4j instancegmlPath
- String
representing path to .gml filepublic static void writeGMLBasic(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String gmlPath)
Node
and
Relationship
properties are written to the GML file.
Consts.COLOR
, Consts.WEIGHT
, Consts.NODE_GID
.
transNeo
- GraphDatabaseService
representing a Neo4j instancegmlPath
- String
representing path to .gml filepublic static void writeMetrics(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String metricsPath)
transNeo
- GraphDatabaseService
representing a Neo4j instancemetricsPath
- String
representing path to .met filepublic static void writeMetricsCSV(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String metricsPath)
transNeo
- GraphDatabaseService
representing a Neo4j instancemetricsPath
- String
representing path to .met filepublic static void appendMetricsCSV(org.neo4j.graphdb.GraphDatabaseService transNeo, java.lang.String metricsPath, java.lang.Long timeStep)
transNeo
- GraphDatabaseService
representing a Neo4j instancemetricsPath
- String
representing path to .met filetimeStep
- Long
representing the time-step/iteration related to
these metricspublic static graph_gen_utils.memory_graph.MemGraph readMemGraph(org.neo4j.graphdb.GraphDatabaseService transNeo)
transNeo
- GraphDatabaseService
representing a Neo4j instance
MemGraph
public static graph_gen_utils.memory_graph.MemGraph readMemGraph(org.neo4j.graphdb.GraphDatabaseService transNeo, java.util.Set<java.lang.String> nodeProps, java.util.Set<java.lang.String> relProps)
public static void removeOrphanNodes(org.neo4j.graphdb.GraphDatabaseService transNeo)
Node
s that do not have at least one
Relationship
from the Neo4j instance.
transNeo
- GraphDatabaseService
representing a Neo4j instancepublic static void removeRelationshipsByType(org.neo4j.graphdb.GraphDatabaseService transNeo, java.util.HashSet<java.lang.String> relTypes)
Relationship
s of the specified
RelationshipType
values (as given by the String
values in
relTypes parameter) from the Neo4j instance.
transNeo
- GraphDatabaseService
representing a Neo4j instancerelTypes
- HashSet
of RelationshipType
representing the
Relationship
s that should be deletedpublic static void removeDuplicateRelationships(org.neo4j.graphdb.GraphDatabaseService transNeo, org.neo4j.graphdb.Direction direction)
Relationship
s (all but one Relationship
between any two Node
s). Useful for reducing the size of a Neo4j
instance while maintaining the same basic connectivity/structure.
Direction
is considered when identifying duplicates.
RelationshipType
is NOT considered (they are all regarded as
equal).
transNeo
- GraphDatabaseService
representing a Neo4j instancedirection
- Direction
which defines what a duplicate is. If
direction equals Direction.OUTGOING
then all but one
outgoing Relationship
s between any two Node
s
are kept. In this case two Relationship
s may exist
between a pair of Node
s. If direction equals
Direction.BOTH
then all but one Relationship
of any direction between any two Node
s is kept.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |