Package org.eclipse.rdf4j.model.util
Class GraphComparisons
- java.lang.Object
-
- org.eclipse.rdf4j.model.util.GraphComparisons
-
class GraphComparisons extends java.lang.Object
Functions for canonicalizing RDF models and computing isomorphism.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
GraphComparisons.Partitioning
Encapsulates 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.HashCode
distinguisher
private static com.google.common.hash.HashFunction
hashFunction
private static com.google.common.hash.HashCode
incoming
private static com.google.common.hash.HashCode
initialHashCode
private static org.slf4j.Logger
logger
private static com.google.common.hash.HashCode
outgoing
-
Constructor Summary
Constructors Constructor Description GraphComparisons()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static BNode
createCanonicalBNode(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.HashCode
hashBag(com.google.common.hash.HashCode... hashCodes)
protected static GraphComparisons.Partitioning
hashBNodes(Model m)
private static GraphComparisons.Partitioning
hashBNodes(Model m, GraphComparisons.Partitioning partitioning)
protected static com.google.common.hash.HashCode
hashTuple(com.google.common.hash.HashCode... hashCodes)
protected static Model
isoCanonicalize(Model m)
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.private static boolean
isomorphicSingleContext(Model model1, Model model2)
private static Model
labelModel(Model original, java.util.Map<BNode,com.google.common.hash.HashCode> hash)
private static boolean
mappingsIncompatible(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)
-
-