Package org.eclipse.rdf4j.model.util
Class GraphComparisons
- java.lang.Object
-
- org.eclipse.rdf4j.model.util.GraphComparisons
-
class GraphComparisons extends java.lang.ObjectFunctions for canonicalizing RDF models and computing isomorphism.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classGraphComparisons.PartitioningEncapsulates the current partitioning state of the algorithm, keeping track of previous and current node:hashcode mappings as well as static value mappings.
-
Field Summary
Fields Modifier and Type Field Description private static com.google.common.hash.HashCodedistinguisherprivate static com.google.common.hash.HashFunctionhashFunctionprivate static com.google.common.hash.HashCodeincomingprivate static com.google.common.hash.HashCodeinitialHashCodeprivate static org.slf4j.Loggerloggerprivate static com.google.common.hash.HashCodeoutgoing
-
Constructor Summary
Constructors Constructor Description GraphComparisons()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static BNodecreateCanonicalBNode(BNode node, java.util.Map<BNode,com.google.common.hash.HashCode> mapping)private static java.util.Map<BNode,com.google.common.hash.HashCode>distinguish(Model m, GraphComparisons.Partitioning partitioning, java.util.Map<BNode,com.google.common.hash.HashCode> lowestFound, java.util.List<BNode> parentFixpoints, java.util.List<java.util.Map<BNode,com.google.common.hash.HashCode>> finePartitionMappings)protected static java.util.Map<BNode,BNode>findCompatibleAutomorphism(java.util.List<BNode> fixpoints, java.util.List<java.util.Map<BNode,com.google.common.hash.HashCode>> partitionMappings)protected static java.util.Set<BNode>getBlankNodes(Model m)protected static java.util.Map<BNode,com.google.common.hash.HashCode>getIsoCanonicalMapping(Model m)protected static com.google.common.hash.HashCodehashBag(com.google.common.hash.HashCode... hashCodes)protected static GraphComparisons.PartitioninghashBNodes(Model m)private static GraphComparisons.PartitioninghashBNodes(Model m, GraphComparisons.Partitioning partitioning)protected static com.google.common.hash.HashCodehashTuple(com.google.common.hash.HashCode... hashCodes)protected static ModelisoCanonicalize(Model m)static booleanisomorphic(Model model1, Model model2)Compares two RDF models, and returns true if they consist of isomorphic graphs and the isomorphic graph identifiers map 1:1 to each other.private static booleanisomorphicSingleContext(Model model1, Model model2)private static ModellabelModel(Model original, java.util.Map<BNode,com.google.common.hash.HashCode> hash)private static booleanmappingsIncompatible(java.util.Map<BNode,com.google.common.hash.HashCode> mapping1, java.util.Map<BNode,com.google.common.hash.HashCode> mapping2)protected static com.google.common.collect.Multimap<com.google.common.hash.HashCode,BNode>partitionMapping(java.util.Map<BNode,com.google.common.hash.HashCode> blankNodeMapping)protected static java.util.List<java.util.Collection<BNode>>partitions(com.google.common.collect.Multimap<com.google.common.hash.HashCode,BNode> partitionMapping)
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
hashFunction
private static final com.google.common.hash.HashFunction hashFunction
-
initialHashCode
private static final com.google.common.hash.HashCode initialHashCode
-
outgoing
private static final com.google.common.hash.HashCode outgoing
-
incoming
private static final com.google.common.hash.HashCode incoming
-
distinguisher
private static final com.google.common.hash.HashCode distinguisher
-
-
Method Detail
-
isomorphic
public static boolean isomorphic(Model model1, Model model2)
Compares two RDF models, and returns true if they consist of isomorphic graphs and the isomorphic graph identifiers map 1:1 to each other. RDF graphs are isomorphic graphs if statements from one graphs can be mapped 1:1 on to statements in the other graphs. In this mapping, blank nodes are not considered mapped when having an identical internal id, but are mapped from one graph to the other by looking at the statements in which the blank nodes occur. A Model can consist of more than one graph (denoted by context identifiers). Two models are considered isomorphic if for each of the graphs in one model, an isomorphic graph exists in the other model, and the context identifiers of these graphs are identical.
-
mappingsIncompatible
private static boolean mappingsIncompatible(java.util.Map<BNode,com.google.common.hash.HashCode> mapping1, java.util.Map<BNode,com.google.common.hash.HashCode> mapping2)
-
getIsoCanonicalMapping
protected static java.util.Map<BNode,com.google.common.hash.HashCode> getIsoCanonicalMapping(Model m)
-
distinguish
private static java.util.Map<BNode,com.google.common.hash.HashCode> distinguish(Model m, GraphComparisons.Partitioning partitioning, java.util.Map<BNode,com.google.common.hash.HashCode> lowestFound, java.util.List<BNode> parentFixpoints, java.util.List<java.util.Map<BNode,com.google.common.hash.HashCode>> finePartitionMappings)
-
findCompatibleAutomorphism
protected static java.util.Map<BNode,BNode> findCompatibleAutomorphism(java.util.List<BNode> fixpoints, java.util.List<java.util.Map<BNode,com.google.common.hash.HashCode>> partitionMappings)
-
partitions
protected static java.util.List<java.util.Collection<BNode>> partitions(com.google.common.collect.Multimap<com.google.common.hash.HashCode,BNode> partitionMapping)
-
partitionMapping
protected static com.google.common.collect.Multimap<com.google.common.hash.HashCode,BNode> partitionMapping(java.util.Map<BNode,com.google.common.hash.HashCode> blankNodeMapping)
-
labelModel
private static Model labelModel(Model original, java.util.Map<BNode,com.google.common.hash.HashCode> hash)
-
hashBNodes
protected static GraphComparisons.Partitioning hashBNodes(Model m)
-
hashBNodes
private static GraphComparisons.Partitioning hashBNodes(Model m, GraphComparisons.Partitioning partitioning)
-
hashTuple
protected static com.google.common.hash.HashCode hashTuple(com.google.common.hash.HashCode... hashCodes)
-
hashBag
protected static com.google.common.hash.HashCode hashBag(com.google.common.hash.HashCode... hashCodes)
-
-