当前位置: 首页>>代码示例>>Java>>正文


Java DTLink类代码示例

本文整理汇总了Java中org.nodes.DTLink的典型用法代码示例。如果您正苦于以下问题:Java DTLink类的具体用法?Java DTLink怎么用?Java DTLink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DTLink类属于org.nodes包,在下文中一共展示了DTLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.nodes.DTLink; //导入依赖的package包/类
private void init(RDFDataSet dataset, List<Resource> instances, List<Statement> blackList) {	
	Set<Statement> stmts = RDFUtils.getStatements4Depth(dataset, instances, depth, inference);
	stmts.removeAll(blackList);
	graph = RDFUtils.statements2Graph(stmts, RDFUtils.REGULAR_LITERALS, instances, true);

	StringTree st = new StringTree();
	for (DTNode<String,String> node : graph.getGraph().nodes()) {
		st.store(node.label());
	}
	for (DTLink<String,String> link : graph.getGraph().links()) {
		st.store(link.tag());
	}

	

}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:17,代码来源:RDFURIPrefixWrapperFeatureVectorKernel.java

示例2: countLabelTagPairs

import org.nodes.DTLink; //导入依赖的package包/类
/**
 * Create a hubmap from a graph
 * 
 * @param graph
 * @return
 */
public static Map<LabelTagPair<String,String>, Integer> countLabelTagPairs(SingleDTGraph graph) {
	Map<LabelTagPair<String,String>, Integer> edgeCounts = new HashMap<LabelTagPair<String,String>, Integer>();
	Set<DTNode<String,String>> iNodes = new HashSet<DTNode<String,String>>(graph.getInstances());

	for (DTLink<String,String> link : graph.getGraph().links()) {
		if (!iNodes.contains(link.from())) { // instance nodes should not be hubs
			LabelTagPair<String,String> heOut = new LabelTagPair<String,String>(link.from().label(), link.tag(), LabelTagPair.DIR_OUT);
			if (!edgeCounts.containsKey(heOut)) {
				edgeCounts.put(heOut, 0);
			}
			edgeCounts.put(heOut, edgeCounts.get(heOut)+1);	
		}
		if (!iNodes.contains(link.to())) {
			LabelTagPair<String,String> heIn = new LabelTagPair<String,String>(link.to().label(), link.tag(), LabelTagPair.DIR_IN);
			if (!edgeCounts.containsKey(heIn)) {
				edgeCounts.put(heIn, 0);
			}
			edgeCounts.put(heIn, edgeCounts.get(heIn)+1);
		}		
	}
	return edgeCounts;
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:29,代码来源:HubUtils.java

示例3: getSubTreesApproxStringLabel

import org.nodes.DTLink; //导入依赖的package包/类
public static GraphList<DTGraph<ApproxStringLabel,ApproxStringLabel>> getSubTreesApproxStringLabel(DTGraph<String,String> graph, List<DTNode<String,String>> instances, int depth) {
	List<DTGraph<ApproxStringLabel,ApproxStringLabel>> subTrees = new ArrayList<DTGraph<ApproxStringLabel,ApproxStringLabel>>();
	List<Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>> searchNodes, newSearchNodes;

	for (DTNode<String,String> startNode : instances) {
		DTGraph<ApproxStringLabel,ApproxStringLabel> newGraph = new LightDTGraph<ApproxStringLabel,ApproxStringLabel>();
		searchNodes = new ArrayList<Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>>();

		// root gets index 0
		searchNodes.add(new Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>(startNode, newGraph.add(new ApproxStringLabel(startNode.label(), depth))));

		for (int i = 0; i < depth; i++) {
			newSearchNodes = new ArrayList<Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>>();
			for (Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>> nodePair : searchNodes) {				
				for (DTLink<String,String> link : nodePair.first().linksOut()) {
					DTNode<ApproxStringLabel,ApproxStringLabel> n2 = newGraph.add(new ApproxStringLabel(link.to().label(), depth - (i+1)));
					newSearchNodes.add(new Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>(link.to(),n2));					
					nodePair.second().connect(n2, new ApproxStringLabel(link.tag(),depth - (i+1)));
				}
			}
			searchNodes = newSearchNodes;
		}
		subTrees.add(newGraph);
	}
	return new GraphList<DTGraph<ApproxStringLabel,ApproxStringLabel>>(subTrees);
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:27,代码来源:RDFUtils.java

示例4: blankLabels

import org.nodes.DTLink; //导入依赖的package包/类
public static SingleDTGraph blankLabels(SingleDTGraph graph) {
	Map<DTNode<String,String>, Integer> ns = new HashMap<DTNode<String,String>,Integer>();
	DTGraph<String,String> newGraph = new LightDTGraph<String,String>();
	List<DTNode<String,String>> newIN = new ArrayList<DTNode<String,String>>();

	for (int i = 0; i < graph.getInstances().size(); i++) {
		ns.put(graph.getInstances().get(i), i);
		newIN.add(null);
	}

	for (DTNode<String,String> n : graph.getGraph().nodes()) {
		if (ns.containsKey(n)) {
			newIN.set(ns.get(n), newGraph.add(""));
		} else {
			newGraph.add("");
		}
	}
	for (DTLink<String,String> l : graph.getGraph().links()) {
		newGraph.nodes().get(l.from().index()).connect(newGraph.nodes().get(l.to().index()), "");
	}
	return new SingleDTGraph(newGraph, newIN);
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:23,代码来源:RDFUtils.java

示例5: simplifyInstanceNodeLabels

import org.nodes.DTLink; //导入依赖的package包/类
public static DTGraph<String,String> simplifyInstanceNodeLabels(DTGraph<String,String> oldGraph, List<DTNode<String,String>> instanceNodes) {
	String rootLabel = KernelUtils.ROOTID;
	Map<DTNode<String,String>, Integer> ns = new HashMap<DTNode<String,String>,Integer>();
	DTGraph<String,String> graph = new LightDTGraph<String,String>();

	for (int i = 0; i < instanceNodes.size(); i++) {
		ns.put(instanceNodes.get(i), i);
	}

	for (DTNode<String,String> n : oldGraph.nodes()) {
		if (ns.containsKey(n)) {
			instanceNodes.set(ns.get(n), graph.add(rootLabel));
		} else {
			graph.add(n.label());
		}
	}
	for (DTLink<String,String> l : oldGraph.links()) {
		graph.nodes().get(l.from().index()).connect(graph.nodes().get(l.to().index()), l.tag());
	}
	return graph;
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:22,代码来源:RDFUtils.java

示例6: computeFVs

import org.nodes.DTLink; //导入依赖的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<MapLabel,MapLabel> graph, List<DTNode<MapLabel,MapLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex) {
	int index;
	Map<DTNode<MapLabel,MapLabel>, Integer> vertexIndexMap;
	Map<DTLink<MapLabel,MapLabel>, Integer> edgeIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (DTNode<MapLabel,MapLabel> vertex : vertexIndexMap.keySet()) {
			if (!vertex.label().getSameAsPrev(vertexIndexMap.get(vertex))) {
				index = Integer.parseInt(vertex.label().get(vertexIndexMap.get(vertex)).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
		edgeIndexMap = instanceEdgeIndexMap.get(instances.get(i));
		for (DTLink<MapLabel,MapLabel> edge : edgeIndexMap.keySet()) {
			if (!edge.tag().getSameAsPrev(edgeIndexMap.get(edge))) {
				index = Integer.parseInt(edge.tag().get(edgeIndexMap.get(edge)).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:35,代码来源:DTGraphWLSubTreeKernel.java

示例7: computeFVs

import org.nodes.DTLink; //导入依赖的package包/类
/**
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<ApproxStringLabel,ApproxStringLabel> graph, List<DTNode<ApproxStringLabel,ApproxStringLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex, int currentIt) {
	int index;
	List<Pair<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer>> vertexIndexMap;
	List<Pair<DTLink<ApproxStringLabel,ApproxStringLabel>, Integer>> edgeIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (Pair<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer> vertex : vertexIndexMap) {
			if ((!noDuplicateSubtrees || vertex.getFirst().label().getSameAsPrev() == 0)  && ((vertex.getSecond() * 2) >= currentIt)) {
				index = Integer.parseInt(vertex.getFirst().label().toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
		edgeIndexMap = instanceEdgeIndexMap.get(instances.get(i));
		for (Pair<DTLink<ApproxStringLabel,ApproxStringLabel>, Integer> edge : edgeIndexMap) {
			if ((!noDuplicateSubtrees || edge.getFirst().tag().getSameAsPrev() == 0) && (((edge.getSecond() * 2)+1) >= currentIt)) {
				index = Integer.parseInt(edge.getFirst().tag().toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:31,代码来源:DTGraphTreeWLSubTreeIDEQApproxKernel.java

示例8: computeFVs

import org.nodes.DTLink; //导入依赖的package包/类
/**
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<MapLabel,MapLabel> graph, List<DTNode<MapLabel,MapLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex) {
	int index;
	List<Pair<DTNode<MapLabel,MapLabel>, Integer>> vertexIndexMap;
	List<Pair<DTLink<MapLabel,MapLabel>, Integer>> edgeIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (Pair<DTNode<MapLabel,MapLabel>, Integer> vertex : vertexIndexMap) {
			if (!vertex.getFirst().label().getSameAsPrev(vertex.getSecond())) {
				index = Integer.parseInt(vertex.getFirst().label().get(vertex.getSecond()).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
		edgeIndexMap = instanceEdgeIndexMap.get(instances.get(i));
		for (Pair<DTLink<MapLabel,MapLabel>, Integer> edge : edgeIndexMap) {
			if (!edge.getFirst().tag().getSameAsPrev(edge.getSecond())) {
				index = Integer.parseInt(edge.getFirst().tag().get(edge.getSecond()).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:31,代码来源:DTGraphTreeWLSubTreeKernel.java

示例9: computeFVs

import org.nodes.DTLink; //导入依赖的package包/类
/**
 * Compute feature vector for the graphs based on the label dictionary created in the previous two steps
 * 
 * @param graphs
 * @param featureVectors
 * @param startLabel
 * @param currentLabel
 */
private void computeFVs(List<DTGraph<StringLabel,StringLabel>> graphs, SparseVector[] featureVectors, double weight, int lastIndex) {
	int index;
	for (int i = 0; i < graphs.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		// for each vertex, use the label as index into the feature vector and do a + 1,
		for (DTNode<StringLabel,StringLabel> vertex : graphs.get(i).nodes()) {
			if (!vertex.label().isSameAsPrev()) {
				index = Integer.parseInt(vertex.label().toString());	
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}

		for (DTLink<StringLabel,StringLabel> edge : graphs.get(i).links()) {
			if (!edge.tag().isSameAsPrev()) {
				index = Integer.parseInt(edge.tag().toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:30,代码来源:WLSubTreeKernel.java

示例10: copyGraphs

import org.nodes.DTLink; //导入依赖的package包/类
private List<DTGraph<ApproxStringLabel,ApproxStringLabel>> copyGraphs(List<DTGraph<ApproxStringLabel,ApproxStringLabel>> oldGraphs) {
	List<DTGraph<ApproxStringLabel,ApproxStringLabel>> newGraphs = new ArrayList<DTGraph<ApproxStringLabel,ApproxStringLabel>>();	

	maxDepth = 0;
	for (DTGraph<ApproxStringLabel,ApproxStringLabel> graph : oldGraphs) {
		LightDTGraph<ApproxStringLabel,ApproxStringLabel> newGraph = new LightDTGraph<ApproxStringLabel,ApproxStringLabel>();
		for (DTNode<ApproxStringLabel,ApproxStringLabel> vertex : graph.nodes()) {
			newGraph.add(new ApproxStringLabel(vertex.label().toString(), vertex.label().getDepth()));
			maxDepth = Math.max(maxDepth, vertex.label().getDepth());
		}
		for (DTLink<ApproxStringLabel,ApproxStringLabel> edge : graph.links()) {
			newGraph.nodes().get(edge.from().index()).connect(newGraph.nodes().get(edge.to().index()), new ApproxStringLabel(edge.tag().toString(), edge.tag().getDepth())); // ?
			maxDepth = Math.max(maxDepth, edge.tag().getDepth());
		}
		newGraphs.add(newGraph);
	}
	return newGraphs;
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:19,代码来源:WLSubTreeApproxKernel.java

示例11: motif

import org.nodes.DTLink; //导入依赖的package包/类
/**
 * The cost of storing the motif
 * 
 * @param graph
 * @param sub
 * @return
 */
public double motif()
{
	double bits = 0.0;
	
	// * Store the structure
	bits += EdgeListCompressor.directed(motif); 
	
	// * Store the labels
	OnlineModel<String> labelModel = new OnlineModel<String>(graph.labels());
	labelModel.addToken(VARIABLE_SYMBOL);
	
	for(DNode<String> node : motif.nodes())
		bits += - Functions.log2(labelModel.observe(node.label()));
	
	// * Store the tags
	OnlineModel<String> tagModel = new OnlineModel<String>(graph.tags());
	tagModel.addToken(VARIABLE_SYMBOL);
	
	for(DTLink<String, String> link : motif.links())
		bits += - Functions.log2(tagModel.observe(link.tag()));
	
	return bits;
}
 
开发者ID:Data2Semantics,项目名称:nodes,代码行数:31,代码来源:MotifVarTags.java

示例12: primeSignature

import org.nodes.DTLink; //导入依赖的package包/类
/**
 * The prime signature of a node in a directed, tagged graph is the combination 
 * of 'in/out' and a tag which occurs most frequently among all links connected
 * to the node.
 * 
 * @param node
 * @return A pair
 */
public static <L, T> Pair<Dir, T> primeSignature(DTNode<L, T> node)
{
	FrequencyModel<Pair<Dir, T>> frequencies = new FrequencyModel<Pair<Dir,T>>();
	
	for(DTLink<L, T> link : node.links())
	{
		// * Ignore self links
		if(link.from().equals(link.to()))
			continue;
		
		Dir dir = link.from().equals(node) ? Dir.OUT : Dir.IN;
		frequencies.add(new Pair<Dir, T>(dir, link.tag()));
	}
	
	return frequencies.maxToken();
}
 
开发者ID:Data2Semantics,项目名称:nodes,代码行数:25,代码来源:SlashBurn.java

示例13: primeDegree

import org.nodes.DTLink; //导入依赖的package包/类
/**
 * @param node
 * @return
 */
public static <L, T> int primeDegree(DTNode<L, T> node)
{
	FrequencyModel<Pair<Dir, T>> frequencies = new FrequencyModel<Pair<Dir,T>>();
	
	for(DTLink<L, T> link : node.links())
	{
		// * Ignore self links
		if(link.from().equals(link.to()))
			continue;
		
		Dir dir = link.from().equals(node) ? Dir.OUT : Dir.IN;
		frequencies.add(new Pair<Dir, T>(dir, link.tag()));
	}
	
	return (int)frequencies.frequency(frequencies.maxToken());
}
 
开发者ID:Data2Semantics,项目名称:nodes,代码行数:21,代码来源:SlashBurn.java

示例14: getSubGraphsApproxStringLabel

import org.nodes.DTLink; //导入依赖的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);
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:35,代码来源:RDFUtils.java

示例15: getSubGraphs

import org.nodes.DTLink; //导入依赖的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);
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:35,代码来源:RDFUtils.java


注:本文中的org.nodes.DTLink类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。