本文整理汇总了Java中org.nodes.DTNode.linksOut方法的典型用法代码示例。如果您正苦于以下问题:Java DTNode.linksOut方法的具体用法?Java DTNode.linksOut怎么用?Java DTNode.linksOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.nodes.DTNode
的用法示例。
在下文中一共展示了DTNode.linksOut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSubGraphsApproxStringLabel
import org.nodes.DTNode; //导入方法依赖的package包/类
public static GraphList<DTGraph<ApproxStringLabel,ApproxStringLabel>> getSubGraphsApproxStringLabel(DTGraph<String,String> graph, List<DTNode<String,String>> instances, int depth) {
List<DTGraph<ApproxStringLabel,ApproxStringLabel>> subGraphs = new ArrayList<DTGraph<ApproxStringLabel,ApproxStringLabel>>();
Map<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>> nodeMap;
Map<DTLink<String,String>,DTLink<ApproxStringLabel,ApproxStringLabel>> linkMap;
List<DTNode<String,String>> searchNodes, newSearchNodes;
for (DTNode<String,String> startNode : instances) {
DTGraph<ApproxStringLabel,ApproxStringLabel> newGraph = new LightDTGraph<ApproxStringLabel,ApproxStringLabel>();
searchNodes = new ArrayList<DTNode<String,String>>();
searchNodes.add(startNode);
nodeMap = new HashMap<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>();
linkMap = new HashMap<DTLink<String,String>,DTLink<ApproxStringLabel,ApproxStringLabel>>();
for (int i = 0; i < depth; i++) {
newSearchNodes = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> node : searchNodes) {
for (DTLink<String,String> link : node.linksOut()) {
if (!nodeMap.containsKey(link.from())) {
nodeMap.put(link.from(), newGraph.add(new ApproxStringLabel(link.from().label(), depth - i)));
}
if (!nodeMap.containsKey(link.to())) {
nodeMap.put(link.to(), newGraph.add(new ApproxStringLabel(link.to().label(), depth - (i+1))));
newSearchNodes.add(link.to());
}
if (!linkMap.containsKey(link)) {
linkMap.put(link, nodeMap.get(link.from()).connect(nodeMap.get(link.to()), new ApproxStringLabel(link.tag(),depth - (i+1))));
}
}
}
searchNodes = newSearchNodes;
}
subGraphs.add(newGraph);
}
return new GraphList<DTGraph<ApproxStringLabel,ApproxStringLabel>>(subGraphs);
}
示例2: getSubGraphs
import org.nodes.DTNode; //导入方法依赖的package包/类
public static GraphList<DTGraph<String,String>> getSubGraphs(DTGraph<String,String> graph, List<DTNode<String,String>> instances, int depth) {
List<DTGraph<String,String>> subGraphs = new ArrayList<DTGraph<String,String>>();
Map<DTNode<String,String>,DTNode<String,String>> nodeMap;
Map<DTLink<String,String>,DTLink<String,String>> linkMap;
List<DTNode<String,String>> searchNodes, newSearchNodes;
for (DTNode<String,String> startNode : instances) {
DTGraph<String,String> newGraph = new LightDTGraph<String,String>();
searchNodes = new ArrayList<DTNode<String,String>>();
searchNodes.add(startNode);
nodeMap = new HashMap<DTNode<String,String>,DTNode<String,String>>();
linkMap = new HashMap<DTLink<String,String>,DTLink<String,String>>();
for (int i = 0; i < depth; i++) {
newSearchNodes = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> node : searchNodes) {
for (DTLink<String,String> link : node.linksOut()) {
if (!nodeMap.containsKey(link.from())) {
nodeMap.put(link.from(), newGraph.add(link.from().label()));
}
if (!nodeMap.containsKey(link.to())) {
nodeMap.put(link.to(), newGraph.add(link.to().label()));
newSearchNodes.add(link.to());
}
if (!linkMap.containsKey(link)) {
linkMap.put(link, nodeMap.get(link.from()).connect(nodeMap.get(link.to()), link.tag()));
}
}
}
searchNodes = newSearchNodes;
}
subGraphs.add(newGraph);
}
return new GraphList<DTGraph<String,String>>(subGraphs);
}
示例3: countPathRec
import org.nodes.DTNode; //导入方法依赖的package包/类
private void countPathRec(SparseVector fv, DTNode<String,String> vertex, String path, int depth) {
// Count path
path = path + vertex.label();
if (!pathDict.containsKey(path)) {
pathDict.put(path, pathDict.size());
}
fv.setValue(pathDict.get(path), fv.getValue(pathDict.get(path)) + 1);
if (depth > 0) {
for (DTLink<String,String> edge : vertex.linksOut()) {
countPathRec(fv, edge, path, depth-1);
}
}
}
示例4: countPathRec
import org.nodes.DTNode; //导入方法依赖的package包/类
private void countPathRec(SparseVector fv, DTNode<String,String> vertex, String path, int depth) {
// Count path
path = path + vertex.label();
if (!pathDict.containsKey(path)) {
pathDict.put(path, pathDict.size());
}
fv.setValue(pathDict.get(path), fv.getValue(pathDict.get(path)) + 1);
if (depth > 0) {
for (DTLink<String,String> edge : vertex.linksOut()) {
countPathRec(fv, edge, path, depth-1);
}
}
}
示例5: computeFVs
import org.nodes.DTNode; //导入方法依赖的package包/类
/**
* The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same
* vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different
* depth labels.
*
* @param graph
* @param instances
* @param weight
* @param featureVectors
*/
private void computeFVs(DTGraph<ApproxStringLabel,ApproxStringLabel> graph, List<DTNode<ApproxStringLabel,ApproxStringLabel>> instances, SparseVector[] featureVectors, int lastIndex) {
List<DTNode<ApproxStringLabel,ApproxStringLabel>> frontV, newFrontV;
for (int i = 0; i < instances.size(); i++) {
Set<DTNode<ApproxStringLabel,ApproxStringLabel>> seenNodes = new HashSet<DTNode<ApproxStringLabel,ApproxStringLabel>>();
Set<DTLink<ApproxStringLabel,ApproxStringLabel>> seenLinks = new HashSet<DTLink<ApproxStringLabel,ApproxStringLabel>>();
featureVectors[i].setLastIndex(lastIndex);
// process inst i
setFV(featureVectors[i], instances.get(i).label().getIterations(), 0);
frontV = new ArrayList<DTNode<ApproxStringLabel,ApproxStringLabel>>();
frontV.add(instances.get(i));
seenNodes.add(instances.get(i));
for (int j = 1; j <= this.depth; j++) {
newFrontV = new ArrayList<DTNode<ApproxStringLabel,ApproxStringLabel>>();
for (DTNode<ApproxStringLabel,ApproxStringLabel> node : frontV) {
for (DTLink<ApproxStringLabel,ApproxStringLabel> link : node.linksOut()) {
if(!seenLinks.contains(link)) {
setFV(featureVectors[i], link.tag().getIterations(), (j * 2) - 1);
seenLinks.add(link);
}
if (!seenNodes.contains(link.to())) {
setFV(featureVectors[i], link.to().label().getIterations(), j * 2);
seenNodes.add(link.to());
// Add the vertex to the new front, if we go into a new round
if (j < this.depth) {
newFrontV.add(link.to());
}
}
}
}
frontV = newFrontV;
}
}
}
示例6: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<PathStringLabel,PathStringLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
List<Pair<DTNode<PathStringLabel,PathStringLabel>, Integer>> vertexIndexMap;
List<Pair<DTLink<PathStringLabel,PathStringLabel>, Integer>> edgeIndexMap;
Map<DTNode<String,String>, DTNode<PathStringLabel,PathStringLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<PathStringLabel,PathStringLabel>>();
Map<DTLink<String,String>, DTLink<PathStringLabel,PathStringLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<PathStringLabel,PathStringLabel>>();
rdfGraph = new LightDTGraph<PathStringLabel,PathStringLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new ArrayList<Pair<DTNode<PathStringLabel,PathStringLabel>, Integer>>();
edgeIndexMap = new ArrayList<Pair<DTLink<PathStringLabel,PathStringLabel>, Integer>>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
if (!labelDict.containsKey(oldStartV.label())) {
labelDict.put(oldStartV.label(), labelDict.size());
}
startV = rdfGraph.add(new PathStringLabel("_" + Integer.toString(labelDict.get(oldStartV.label()))));
vOldNewMap.put(oldStartV, startV);
}
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.add(new Pair<DTNode<PathStringLabel,PathStringLabel>,Integer>(startV, depth));
startV.label().updateMaxDepth(depth);
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
vertexIndexMap.add(new Pair<DTNode<PathStringLabel,PathStringLabel>,Integer>(vOldNewMap.get(edge.to()), j));
vOldNewMap.get(edge.to()).label().updateMaxDepth(j);
} else {
if (!labelDict.containsKey(edge.to().label())) {
labelDict.put(edge.to().label(), labelDict.size());
}
DTNode<PathStringLabel,PathStringLabel> newN = rdfGraph.add(new PathStringLabel("_" + Integer.toString(labelDict.get(edge.to().label()))));
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.add(new Pair<DTNode<PathStringLabel,PathStringLabel>,Integer>(newN, j));
newN.label().updateMaxDepth(j);
}
if (eOldNewMap.containsKey(edge)) {
edgeIndexMap.add(new Pair<DTLink<PathStringLabel,PathStringLabel>,Integer>(eOldNewMap.get(edge), j));
eOldNewMap.get(edge).tag().updateMaxDepth(j);
} else {
if (!labelDict.containsKey(edge.tag())) {
labelDict.put(edge.tag(), labelDict.size());
}
DTLink<PathStringLabel,PathStringLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new PathStringLabel("_" + Integer.toString(labelDict.get(edge.tag()))));
eOldNewMap.put(edge, newE);
edgeIndexMap.add(new Pair<DTLink<PathStringLabel,PathStringLabel>,Integer>(newE, j));
newE.tag().updateMaxDepth(j);
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例7: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<PathStringMapLabel,PathStringMapLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
List<Pair<DTNode<PathStringMapLabel,PathStringMapLabel>, Integer>> vertexIndexMap;
List<Pair<DTLink<PathStringMapLabel,PathStringMapLabel>, Integer>> edgeIndexMap;
Map<DTNode<String,String>, DTNode<PathStringMapLabel,PathStringMapLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<PathStringMapLabel,PathStringMapLabel>>();
Map<DTLink<String,String>, DTLink<PathStringMapLabel,PathStringMapLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<PathStringMapLabel,PathStringMapLabel>>();
rdfGraph = new LightDTGraph<PathStringMapLabel,PathStringMapLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new ArrayList<Pair<DTNode<PathStringMapLabel,PathStringMapLabel>, Integer>>();
edgeIndexMap = new ArrayList<Pair<DTLink<PathStringMapLabel,PathStringMapLabel>, Integer>>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
if (!labelDict.containsKey(oldStartV.label())) {
labelDict.put(oldStartV.label(), labelDict.size());
}
startV = rdfGraph.add(new PathStringMapLabel("_" + Integer.toString(labelDict.get(oldStartV.label()))));
vOldNewMap.put(oldStartV, startV);
}
startV.label().initDepth(depth);
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.add(new Pair<DTNode<PathStringMapLabel,PathStringMapLabel>,Integer>(startV, depth));
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
vertexIndexMap.add(new Pair<DTNode<PathStringMapLabel,PathStringMapLabel>,Integer>(vOldNewMap.get(edge.to()), j));
vOldNewMap.get(edge.to()).label().initDepth(j); // However, we should always include it in the graph at depth j
} else {
if (!labelDict.containsKey(edge.to().label())) {
labelDict.put(edge.to().label(), labelDict.size());
}
DTNode<PathStringMapLabel,PathStringMapLabel> newN = rdfGraph.add(new PathStringMapLabel("_" + Integer.toString(labelDict.get(edge.to().label()))));
newN.label().initDepth(j);
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.add(new Pair<DTNode<PathStringMapLabel,PathStringMapLabel>,Integer>(newN, j));
}
if (eOldNewMap.containsKey(edge)) {
edgeIndexMap.add(new Pair<DTLink<PathStringMapLabel,PathStringMapLabel>,Integer>(eOldNewMap.get(edge), j));
eOldNewMap.get(edge).tag().initDepth(j);
} else {
if (!labelDict.containsKey(edge.tag())) {
labelDict.put(edge.tag(), labelDict.size());
}
DTLink<PathStringMapLabel,PathStringMapLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new PathStringMapLabel("_" + Integer.toString(labelDict.get(edge.tag()))));
newE.tag().initDepth(j);
eOldNewMap.put(edge, newE);
edgeIndexMap.add(new Pair<DTLink<PathStringMapLabel,PathStringMapLabel>,Integer>(newE, j));
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例8: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<PathStringLabel,PathStringLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
Map<DTNode<PathStringLabel,PathStringLabel>, Integer> vertexIndexMap;
Map<DTLink<PathStringLabel,PathStringLabel>, Integer> edgeIndexMap;
Map<DTNode<String,String>, DTNode<PathStringLabel,PathStringLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<PathStringLabel,PathStringLabel>>();
Map<DTLink<String,String>, DTLink<PathStringLabel,PathStringLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<PathStringLabel,PathStringLabel>>();
rdfGraph = new LightDTGraph<PathStringLabel,PathStringLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new HashMap<DTNode<PathStringLabel,PathStringLabel>, Integer>();
edgeIndexMap = new HashMap<DTLink<PathStringLabel,PathStringLabel>, Integer>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
if (!labelDict.containsKey(oldStartV.label())) {
labelDict.put(oldStartV.label(), labelDict.size());
}
startV = rdfGraph.add(new PathStringLabel(Integer.toString(labelDict.get(oldStartV.label()))));
vOldNewMap.put(oldStartV, startV);
}
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.put(startV, depth);
startV.label().updateMaxDepth(depth);
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
if (!vertexIndexMap.containsKey(vOldNewMap.get(edge.to()))) { // we have not seen it for this instance
vertexIndexMap.put(vOldNewMap.get(edge.to()), j);
vOldNewMap.get(edge.to()).label().updateMaxDepth(j);
}
} else {
if (!labelDict.containsKey(edge.to().label())) {
labelDict.put(edge.to().label(), labelDict.size());
}
DTNode<PathStringLabel,PathStringLabel> newN = rdfGraph.add(new PathStringLabel("_" + Integer.toString(labelDict.get(edge.to().label()))));
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.put(newN, j);
newN.label().updateMaxDepth(j);
}
if (eOldNewMap.containsKey(edge)) {
// Process the edge, if we haven't seen it before
if (!edgeIndexMap.containsKey(eOldNewMap.get(edge))) {
edgeIndexMap.put(eOldNewMap.get(edge), j);
eOldNewMap.get(edge).tag().updateMaxDepth(j);
}
} else {
if (!labelDict.containsKey(edge.tag())) {
labelDict.put(edge.tag(), labelDict.size());
}
DTLink<PathStringLabel,PathStringLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new PathStringLabel("_" + Integer.toString(labelDict.get(edge.tag()))));
eOldNewMap.put(edge, newE);
edgeIndexMap.put(newE, j);
newE.tag().updateMaxDepth(j);
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例9: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<MapLabel,MapLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
Map<DTNode<MapLabel,MapLabel>, Integer> vertexIndexMap;
Map<DTLink<MapLabel,MapLabel>, Integer> edgeIndexMap;
Map<DTNode<String,String>, DTNode<MapLabel,MapLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<MapLabel,MapLabel>>();
Map<DTLink<String,String>, DTLink<MapLabel,MapLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<MapLabel,MapLabel>>();
rdfGraph = new LightDTGraph<MapLabel,MapLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new HashMap<DTNode<MapLabel,MapLabel>, Integer>();
edgeIndexMap = new HashMap<DTLink<MapLabel,MapLabel>, Integer>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
startV = rdfGraph.add(new MapLabel());
vOldNewMap.put(oldStartV, startV);
}
startV.label().put(depth, new StringBuilder(oldStartV.label()));
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.put(startV, depth);
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
if (!vertexIndexMap.containsKey(vOldNewMap.get(edge.to())) || !reverse) { // we have not seen it for this instance or labels travel to the fringe vertices, in which case we want to have the lowest depth encounter
vertexIndexMap.put(vOldNewMap.get(edge.to()), j);
}
vOldNewMap.get(edge.to()).label().put(j, new StringBuilder(edge.to().label())); // However, we should always include it in the graph at depth j
} else {
DTNode<MapLabel,MapLabel> newN = rdfGraph.add(new MapLabel());
newN.label().put(j, new StringBuilder(edge.to().label()));
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.put(newN, j);
}
if (eOldNewMap.containsKey(edge)) {
// Process the edge, if we haven't seen it before
if (!edgeIndexMap.containsKey(eOldNewMap.get(edge)) || !reverse) { // see comment for vertices
edgeIndexMap.put(eOldNewMap.get(edge), j);
}
eOldNewMap.get(edge).tag().put(j, new StringBuilder(edge.tag()));
} else {
DTLink<MapLabel,MapLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new MapLabel());
newE.tag().put(j, new StringBuilder(edge.tag()));
eOldNewMap.put(edge, newE);
edgeIndexMap.put(newE, j);
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例10: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<StringLabel,StringLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
List<Pair<DTNode<StringLabel,StringLabel>, Integer>> vertexIndexMap;
List<Pair<DTLink<StringLabel,StringLabel>, Integer>> edgeIndexMap;
Map<DTNode<String,String>, DTNode<StringLabel,StringLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<StringLabel,StringLabel>>();
Map<DTLink<String,String>, DTLink<StringLabel,StringLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<StringLabel,StringLabel>>();
instanceVertices = new ArrayList<DTNode<StringLabel,StringLabel>>();
instanceVertexIndexMap = new HashMap<DTNode<StringLabel,StringLabel>, List<Pair<DTNode<StringLabel,StringLabel>, Integer>>>();
instanceEdgeIndexMap = new HashMap<DTNode<StringLabel,StringLabel>, List<Pair<DTLink<StringLabel,StringLabel>, Integer>>>();
rdfGraph = new LightDTGraph<StringLabel,StringLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new ArrayList<Pair<DTNode<StringLabel,StringLabel>, Integer>>();
edgeIndexMap = new ArrayList<Pair<DTLink<StringLabel,StringLabel>, Integer>>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
startV = rdfGraph.add(new StringLabel());
vOldNewMap.put(oldStartV, startV);
}
startV.label().clear();
startV.label().append(oldStartV.label());
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.add(new Pair<DTNode<StringLabel,StringLabel>,Integer>(startV, depth));
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
vertexIndexMap.add(new Pair<DTNode<StringLabel,StringLabel>,Integer>(vOldNewMap.get(edge.to()), j));
vOldNewMap.get(edge.to()).label().clear();
vOldNewMap.get(edge.to()).label().append(edge.to().label());
} else {
DTNode<StringLabel,StringLabel> newN = rdfGraph.add(new StringLabel());
newN.label().clear();
newN.label().append(edge.to().label());
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.add(new Pair<DTNode<StringLabel,StringLabel>,Integer>(newN, j));
}
if (eOldNewMap.containsKey(edge)) {
edgeIndexMap.add(new Pair<DTLink<StringLabel,StringLabel>,Integer>(eOldNewMap.get(edge),j));
eOldNewMap.get(edge).tag().clear();
eOldNewMap.get(edge).tag().append(edge.tag());
} else {
DTLink<StringLabel,StringLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new StringLabel());
newE.tag().clear();
newE.tag().append(edge.tag());
eOldNewMap.put(edge, newE);
edgeIndexMap.add(new Pair<DTLink<StringLabel,StringLabel>,Integer>(newE, j));
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例11: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<ApproxStringLabel,ApproxStringLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
List<Pair<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer>> vertexIndexMap;
List<Pair<DTLink<ApproxStringLabel,ApproxStringLabel>, Integer>> edgeIndexMap;
Map<DTNode<String,String>, DTNode<ApproxStringLabel,ApproxStringLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>();
Map<DTLink<String,String>, DTLink<ApproxStringLabel,ApproxStringLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<ApproxStringLabel,ApproxStringLabel>>();
instanceVertices = new ArrayList<DTNode<ApproxStringLabel,ApproxStringLabel>>();
instanceVertexIndexMap = new HashMap<DTNode<ApproxStringLabel,ApproxStringLabel>, List<Pair<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer>>>();
instanceEdgeIndexMap = new HashMap<DTNode<ApproxStringLabel,ApproxStringLabel>, List<Pair<DTLink<ApproxStringLabel,ApproxStringLabel>, Integer>>>();
rdfGraph = new LightDTGraph<ApproxStringLabel,ApproxStringLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new ArrayList<Pair<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer>>();
edgeIndexMap = new ArrayList<Pair<DTLink<ApproxStringLabel,ApproxStringLabel>, Integer>>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
startV = rdfGraph.add(new ApproxStringLabel());
vOldNewMap.put(oldStartV, startV);
}
startV.label().clear();
startV.label().append(oldStartV.label());
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.add(new Pair<DTNode<ApproxStringLabel,ApproxStringLabel>,Integer>(startV, depth));
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
vertexIndexMap.add(new Pair<DTNode<ApproxStringLabel,ApproxStringLabel>,Integer>(vOldNewMap.get(edge.to()), j));
vOldNewMap.get(edge.to()).label().clear();
vOldNewMap.get(edge.to()).label().append(edge.to().label());
} else {
DTNode<ApproxStringLabel,ApproxStringLabel> newN = rdfGraph.add(new ApproxStringLabel());
newN.label().clear();
newN.label().append(edge.to().label());
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.add(new Pair<DTNode<ApproxStringLabel,ApproxStringLabel>,Integer>(newN, j));
}
if (eOldNewMap.containsKey(edge)) {
edgeIndexMap.add(new Pair<DTLink<ApproxStringLabel,ApproxStringLabel>,Integer>(eOldNewMap.get(edge),j));
eOldNewMap.get(edge).tag().clear();
eOldNewMap.get(edge).tag().append(edge.tag());
} else {
DTLink<ApproxStringLabel,ApproxStringLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new ApproxStringLabel());
newE.tag().clear();
newE.tag().append(edge.tag());
eOldNewMap.put(edge, newE);
edgeIndexMap.add(new Pair<DTLink<ApproxStringLabel,ApproxStringLabel>,Integer>(newE, j));
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例12: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<PathStringMapLabel,PathStringMapLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
Map<DTNode<PathStringMapLabel,PathStringMapLabel>, Integer> vertexIndexMap;
Map<DTLink<PathStringMapLabel,PathStringMapLabel>, Integer> edgeIndexMap;
Map<DTNode<String,String>, DTNode<PathStringMapLabel,PathStringMapLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<PathStringMapLabel,PathStringMapLabel>>();
Map<DTLink<String,String>, DTLink<PathStringMapLabel,PathStringMapLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<PathStringMapLabel,PathStringMapLabel>>();
rdfGraph = new LightDTGraph<PathStringMapLabel,PathStringMapLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new HashMap<DTNode<PathStringMapLabel,PathStringMapLabel>, Integer>();
edgeIndexMap = new HashMap<DTLink<PathStringMapLabel,PathStringMapLabel>, Integer>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
if (!labelDict.containsKey(oldStartV.label())) {
labelDict.put(oldStartV.label(), labelDict.size());
}
startV = rdfGraph.add(new PathStringMapLabel(Integer.toString(labelDict.get(oldStartV.label()))));
vOldNewMap.put(oldStartV, startV);
}
startV.label().initDepth(depth);
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.put(startV, depth);
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
if (!vertexIndexMap.containsKey(vOldNewMap.get(edge.to()))) { // we have not seen it for this instance
vertexIndexMap.put(vOldNewMap.get(edge.to()), j);
}
vOldNewMap.get(edge.to()).label().initDepth(j); // However, we should always include it in the graph at depth j
} else {
if (!labelDict.containsKey(edge.to().label())) {
labelDict.put(edge.to().label(), labelDict.size());
}
DTNode<PathStringMapLabel,PathStringMapLabel> newN = rdfGraph.add(new PathStringMapLabel("_" + Integer.toString(labelDict.get(edge.to().label()))));
newN.label().initDepth(j);
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.put(newN, j);
}
if (eOldNewMap.containsKey(edge)) {
// Process the edge, if we haven't seen it before
if (!edgeIndexMap.containsKey(eOldNewMap.get(edge))) {
edgeIndexMap.put(eOldNewMap.get(edge), j);
}
eOldNewMap.get(edge).tag().initDepth(j);
} else {
if (!labelDict.containsKey(edge.tag())) {
labelDict.put(edge.tag(), labelDict.size());
}
DTLink<PathStringMapLabel,PathStringMapLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new PathStringMapLabel("_" + Integer.toString(labelDict.get(edge.tag()))));
newE.tag().initDepth(j);
eOldNewMap.put(edge, newE);
edgeIndexMap.put(newE, j);
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例13: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<MapLabel,MapLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
Map<DTNode<MapLabel,MapLabel>, Integer> vertexIndexMap;
Map<DTLink<MapLabel,MapLabel>, Integer> edgeIndexMap;
Map<DTNode<String,String>, DTNode<MapLabel,MapLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<MapLabel,MapLabel>>();
Map<DTLink<String,String>, DTLink<MapLabel,MapLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<MapLabel,MapLabel>>();
rdfGraph = new LightDTGraph<MapLabel,MapLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new HashMap<DTNode<MapLabel,MapLabel>, Integer>();
edgeIndexMap = new HashMap<DTLink<MapLabel,MapLabel>, Integer>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
startV = rdfGraph.add(new MapLabel());
vOldNewMap.put(oldStartV, startV);
}
startV.label().put(depth, new StringBuilder(oldStartV.label()));
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.put(startV, depth);
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
if (!vertexIndexMap.containsKey(vOldNewMap.get(edge.to()))) { // we have not seen it for this instance
vertexIndexMap.put(vOldNewMap.get(edge.to()), j);
}
vOldNewMap.get(edge.to()).label().put(j, new StringBuilder(edge.to().label())); // However, we should always include it in the graph at depth j
} else {
DTNode<MapLabel,MapLabel> newN = rdfGraph.add(new MapLabel());
newN.label().put(j, new StringBuilder(edge.to().label()));
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.put(newN, j);
}
if (eOldNewMap.containsKey(edge)) {
// Process the edge, if we haven't seen it before
if (!edgeIndexMap.containsKey(eOldNewMap.get(edge))) { // see comment for vertices
edgeIndexMap.put(eOldNewMap.get(edge), j);
}
eOldNewMap.get(edge).tag().put(j, new StringBuilder(edge.tag()));
} else {
DTLink<MapLabel,MapLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new MapLabel());
newE.tag().put(j, new StringBuilder(edge.tag()));
eOldNewMap.put(edge, newE);
edgeIndexMap.put(newE, j);
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}
示例14: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<ApproxStringLabel,ApproxStringLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
Map<DTNode<String,String>, DTNode<ApproxStringLabel,ApproxStringLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>();
Map<DTLink<String,String>, DTLink<ApproxStringLabel,ApproxStringLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<ApproxStringLabel,ApproxStringLabel>>();
rdfGraph = new LightDTGraph<ApproxStringLabel,ApproxStringLabel>();
instanceVertices = new ArrayList<DTNode<ApproxStringLabel,ApproxStringLabel>>();
int instanceIndex = 0;
for (DTNode<String,String> oldStartV : instances) {
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
startV = rdfGraph.add(new ApproxStringLabel());
vOldNewMap.put(oldStartV, startV);
}
startV.label().clear();
startV.label().append(oldStartV.label());
startV.label().addInstanceIndex(instanceIndex);
instanceVertices.add(startV);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (!vOldNewMap.containsKey(edge.to())) { // This vertex has not been added to rdfGraph
DTNode<ApproxStringLabel,ApproxStringLabel> newN = rdfGraph.add(new ApproxStringLabel());
newN.label().clear();
newN.label().append(edge.to().label());
vOldNewMap.put(edge.to(), newN);
}
vOldNewMap.get(edge.to()).label().addInstanceIndex(instanceIndex);
if (!eOldNewMap.containsKey(edge)) {
DTLink<ApproxStringLabel,ApproxStringLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new ApproxStringLabel());
newE.tag().clear();
newE.tag().append(edge.tag());
eOldNewMap.put(edge, newE);
}
eOldNewMap.get(edge).tag().addInstanceIndex(instanceIndex);
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
instanceIndex++;
}
}
示例15: init
import org.nodes.DTNode; //导入方法依赖的package包/类
private void init(DTGraph<String,String> graph, List<DTNode<String,String>> instances) {
DTNode<MapLabel,MapLabel> startV;
List<DTNode<String,String>> frontV, newFrontV;
List<Pair<DTNode<MapLabel,MapLabel>, Integer>> vertexIndexMap;
List<Pair<DTLink<MapLabel,MapLabel>, Integer>> edgeIndexMap;
Map<DTNode<String,String>, DTNode<MapLabel,MapLabel>> vOldNewMap = new HashMap<DTNode<String,String>,DTNode<MapLabel,MapLabel>>();
Map<DTLink<String,String>, DTLink<MapLabel,MapLabel>> eOldNewMap = new HashMap<DTLink<String,String>,DTLink<MapLabel,MapLabel>>();
instanceVertices = new ArrayList<DTNode<MapLabel,MapLabel>>();
instanceVertexIndexMap = new HashMap<DTNode<MapLabel,MapLabel>, List<Pair<DTNode<MapLabel,MapLabel>, Integer>>>();
instanceEdgeIndexMap = new HashMap<DTNode<MapLabel,MapLabel>, List<Pair<DTLink<MapLabel,MapLabel>, Integer>>>();
rdfGraph = new LightDTGraph<MapLabel,MapLabel>();
for (DTNode<String,String> oldStartV : instances) {
vertexIndexMap = new ArrayList<Pair<DTNode<MapLabel,MapLabel>, Integer>>();
edgeIndexMap = new ArrayList<Pair<DTLink<MapLabel,MapLabel>, Integer>>();
// Get the start node
if (vOldNewMap.containsKey(oldStartV)) {
startV = vOldNewMap.get(oldStartV);
} else {
startV = rdfGraph.add(new MapLabel());
vOldNewMap.put(oldStartV, startV);
}
startV.label().put(depth, new StringBuilder(oldStartV.label()));
instanceVertices.add(startV);
instanceVertexIndexMap.put(startV, vertexIndexMap);
instanceEdgeIndexMap.put(startV, edgeIndexMap);
frontV = new ArrayList<DTNode<String,String>>();
frontV.add(oldStartV);
// Process the start node
vertexIndexMap.add(new Pair<DTNode<MapLabel,MapLabel>,Integer>(startV, depth));
for (int j = depth - 1; j >= 0; j--) {
newFrontV = new ArrayList<DTNode<String,String>>();
for (DTNode<String,String> qV : frontV) {
for (DTLink<String,String> edge : qV.linksOut()) {
if (vOldNewMap.containsKey(edge.to())) { // This vertex has been added to rdfGraph
vertexIndexMap.add(new Pair<DTNode<MapLabel,MapLabel>,Integer>(vOldNewMap.get(edge.to()), j));
vOldNewMap.get(edge.to()).label().put(j, new StringBuilder(edge.to().label()));
} else {
DTNode<MapLabel,MapLabel> newN = rdfGraph.add(new MapLabel());
newN.label().put(j, new StringBuilder(edge.to().label()));
vOldNewMap.put(edge.to(), newN);
vertexIndexMap.add(new Pair<DTNode<MapLabel,MapLabel>,Integer>(newN, j));
}
if (eOldNewMap.containsKey(edge)) {
edgeIndexMap.add(new Pair<DTLink<MapLabel,MapLabel>,Integer>(eOldNewMap.get(edge),j));
eOldNewMap.get(edge).tag().put(j, new StringBuilder(edge.tag()));
} else {
DTLink<MapLabel,MapLabel> newE = vOldNewMap.get(qV).connect(vOldNewMap.get(edge.to()), new MapLabel());
newE.tag().put(j, new StringBuilder(edge.tag()));
eOldNewMap.put(edge, newE);
edgeIndexMap.add(new Pair<DTLink<MapLabel,MapLabel>,Integer>(newE, j));
}
// Add the vertex to the new front, if we go into a new round
if (j > 0) {
newFrontV.add(edge.to());
}
}
}
frontV = newFrontV;
}
}
}