本文整理汇总了Java中it.unimi.dsi.fastutil.longs.Long2LongMap类的典型用法代码示例。如果您正苦于以下问题:Java Long2LongMap类的具体用法?Java Long2LongMap怎么用?Java Long2LongMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Long2LongMap类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了Long2LongMap类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pickUpSampling
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
private int pickUpSampling(long seconds, long start, int last, Long2LongMap buckets) {
if (seconds < start) {
return 1;
}
long sample = 0;
for (Long2LongMap.Entry e : buckets.long2LongEntrySet()) {
if (seconds < e.getLongKey()) {
sample = e.getLongValue();
break;
}
}
if (sample == 0) {
return last;
}
return (int) sample;
}
示例2: computeNewLabel
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
private long computeNewLabel(Node node) {
// Count the frequency of labels at neighbours of the current node
labelCounts.clear();
labelCounts.defaultReturnValue(0L);
for (Relationship relationship : node.getRelationships(EDGE, Direction.BOTH)) {
long otherLabel = labels.get(relationship.getOtherNode(node));
labelCounts.put(otherLabel, labelCounts.get(otherLabel) + 1);
}
// Find the most frequent label with the lowest id
long bestLabel = labels.get(node);
long bestFrequency = 0;
for (Long2LongMap.Entry labelFrequencyPair : labelCounts.long2LongEntrySet()) {
long nextLabel = labelFrequencyPair.getLongKey();
long nextFrequency = labelFrequencyPair.getLongValue();
if (nextFrequency > bestFrequency) {
bestLabel = nextLabel;
bestFrequency = nextFrequency;
} else if (nextFrequency == bestFrequency && nextLabel < bestLabel) {
bestLabel = nextLabel;
}
}
return bestLabel;
}
开发者ID:atlarge-research,项目名称:graphalytics-platforms-neo4j,代码行数:25,代码来源:CommunityDetectionLPComputation.java
示例3: getMostFrequentLabel
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
protected long getMostFrequentLabel(Node node) {
Long2LongMap commMap = new Long2LongOpenHashMap();
Iterable<Relationship> relationships = relType == null ? node.getRelationships() : node.getRelationships(relType);
for (Relationship r : relationships) {
Node other = r.getOtherNode(node);
long otherCommunity = (long) other.getProperty(attName);
// commMap.put(other.getId(), otherCommunity); WRONG
long count = commMap.getOrDefault(otherCommunity, 0L);
commMap.put(otherCommunity, count+1);
}
long mostFrequentLabel = -1;
long mostFrequentLabelCount = -1;
for( Entry<Long, Long> e : commMap.entrySet() ) {
if( e.getValue() > mostFrequentLabelCount ) {
mostFrequentLabelCount = e.getValue();
mostFrequentLabel = e.getKey();
}
}
return mostFrequentLabel;
}
示例4: contains
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
@Override
public boolean contains(long address) {
if (indexedMemoryAccessChecker != null) {
int result = indexedMemoryAccessChecker.isAllocated(address);
if (result == IndexedMemoryAccessChecker.ALLOCATED) {
return true;
} else if (result == IndexedMemoryAccessChecker.NOT_ALLOCATED) {
return false;
}
// Not indexed, so check over allocated memories
}
Long2LongMap.Entry entry = allocatedMemories.tailMap(address).long2LongEntrySet().first();
if (entry == null) {
return false;
}
long startAddress = entry.getLongKey();
long endAddress = startAddress + entry.getLongValue();
return address >= startAddress && address <= endAddress;
}
示例5: uploadGraph
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
@Override
public void uploadGraph(Graph graph) throws Exception {
LOG.info("Importing graph \"{}\" into a Neo4j database", graph.getName());
String databasePath = Paths.get(dbPath, graph.getName()).toString();
InputStream propertiesStream = getClass().getResourceAsStream(PROPERTIES_PATH);
Map<String, String> properties = MapUtil.load(propertiesStream);
BatchInserter inserter = BatchInserters.inserter(databasePath, properties);
LOG.debug("- Inserting vertices");
Long2LongMap vertexIdMap = new Long2LongOpenHashMap((int)graph.getNumberOfVertices());
try (BufferedReader vertexData = new BufferedReader(new FileReader(graph.getVertexFilePath()))) {
Map<String, Object> propertiesCache = new HashMap<>(1, 1.0f);
for (String vertexLine = vertexData.readLine(); vertexLine != null; vertexLine = vertexData.readLine()) {
if (vertexLine.isEmpty()) {
continue;
}
long vertexId = Long.parseLong(vertexLine);
propertiesCache.put(ID_PROPERTY, vertexId);
long internalVertexId = inserter.createNode(propertiesCache, (Label)Vertex);
vertexIdMap.put(vertexId, internalVertexId);
}
}
LOG.debug("- Inserting edges");
try (BufferedReader edgeData = new BufferedReader(new FileReader(graph.getEdgeFilePath()))) {
for (String edgeLine = edgeData.readLine(); edgeLine != null; edgeLine = edgeData.readLine()) {
if (edgeLine.isEmpty()) {
continue;
}
String[] edgeLineChunks = edgeLine.split(" ");
if (edgeLineChunks.length != 2) {
throw new IOException("Invalid data found in edge list: \"" + edgeLine + "\"");
}
inserter.createRelationship(vertexIdMap.get(Long.parseLong(edgeLineChunks[0])),
vertexIdMap.get(Long.parseLong(edgeLineChunks[1])), EDGE, null);
}
}
inserter.createDeferredSchemaIndex(Vertex).on(ID_PROPERTY).create();
inserter.shutdown();
LOG.debug("- Graph \"{}\" imported successfully", graph.getName());
}
示例6: getCoder
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
@Override
public Coder getCoder(final Long2LongMap frequencies) {
assert Longs.min(frequencies.values().toLongArray()) > 0;
return new Coder(Fast.length(Longs.max(frequencies.keySet().toLongArray())));
}
示例7: getResult
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
public Long2LongMap getResult() {
return this.componentsMap;
}
示例8: getNode2CommunityMap
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
public Long2LongMap getNode2CommunityMap() {
return node2CommunityMap;
}
示例9: getResult
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
@Override
public Long2LongMap getResult() {
return lp.getResult();
}
示例10: getResult
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
@Override
public Long2LongMap getResult() {
return communityMap;
}
示例11: getResult
import it.unimi.dsi.fastutil.longs.Long2LongMap; //导入依赖的package包/类
@Override
public Long2LongMap getResult() {
return this.triangleMap;
}