本文整理了Java中org.gephi.graph.api.Graph.readUnlock()
方法的一些代码示例,展示了Graph.readUnlock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.readUnlock()
方法的具体详情如下:
包路径:org.gephi.graph.api.Graph
类名称:Graph
方法名:readUnlock
[英]Closes a read lock for the current thread.
[中]关闭当前线程的读取锁。
代码示例来源:origin: org.gephi/tools-plugin
public static Node[] getNeighbors(Graph graph, Node[] nodes) {
Set<Node> nodeTree = new HashSet<>();
graph.readLock();
try {
for (Node n : nodes) {
nodeTree.addAll(graph.getNeighbors(n).toCollection());
}
} finally {
graph.readUnlock();
}
//remove original nodes
for (Node n : nodes) {
nodeTree.remove(n);
}
return nodeTree.toArray(new Node[0]);
}
代码示例来源:origin: org.gephi/tools-plugin
public static Node[] getNeighborsOfNeighbors(Graph graph, Node[] nodes) {
Set<Node> nodeTree = new HashSet<>();
graph.readLock();
try {
for (Node n : nodes) {
nodeTree.addAll(graph.getNeighbors(n).toCollection());
}
//remove original nodes
for (Node n : nodes) {
nodeTree.remove(n);
}
for (Node n : nodeTree.toArray(new Node[0])) {
nodeTree.addAll(graph.getNeighbors(n).toCollection());
}
} finally {
graph.readUnlock();
}
//remove original nodes
for (Node n : nodes) {
nodeTree.remove(n);
}
return nodeTree.toArray(new Node[0]);
}
代码示例来源:origin: gephi/gephi-plugins-bootcamp
@Override
public void select() {
//Get current visible graph
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
Graph graph = graphController.getGraphModel().getGraphVisible();
//Build the autocomplete data. A simple map from node's label
graph.readLock();
data = new HashMap<String, Node>();
for (Node n : graph.getNodes()) {
String label = n.getLabel();
String id = n.getId().toString();
if (label != null) {
if (!label.isEmpty()) {
data.put(label, n);
}
} else if (id != null && !id.isEmpty()) {
data.put(id, n);
}
}
graph.readUnlock();
}
代码示例来源:origin: org.gephi/statistics-plugin
public void execute(Graph graph) {
isCanceled = false;
initializeAttributeColunms(graph.getModel());
graph.readLock();
try {
N = graph.getNodeCount();
initializeStartValues();
HashMap<Node, Integer> indicies = createIndiciesMap(graph);
Map<String, double[]> metrics = calculateDistanceMetrics(graph, indicies, isDirected, isNormalized);
eccentricity = metrics.get(ECCENTRICITY);
closeness = metrics.get(CLOSENESS);
harmonicCloseness = metrics.get(HARMONIC_CLOSENESS);
betweenness = metrics.get(BETWEENNESS);
saveCalculatedValues(graph, indicies, eccentricity, betweenness, closeness, harmonicCloseness);
} finally {
graph.readUnlock();
}
}
代码示例来源:origin: org.gephi/statistics-plugin
public void execute(Graph graph) {
isCanceled = false;
graph.readLock();
try {
structure = new Modularity.CommunityStructure(graph);
int[] comStructure = new int[graph.getNodeCount()];
if (graph.getNodeCount() > 0) {//Fixes issue #713 Modularity Calculation Throws Exception On Empty Graph
HashMap<String, Double> computedModularityMetrics = computeModularity(graph, structure, comStructure, resolution, isRandomized, useWeight);
modularity = computedModularityMetrics.get("modularity");
modularityResolution = computedModularityMetrics.get("modularityResolution");
} else {
modularity = 0;
modularityResolution = 0;
}
saveValues(comStructure, graph, structure);
} finally {
graph.readUnlock();
}
}
代码示例来源:origin: org.gephi/graphstore
public void indexView(Graph graph) {
TimeIndexImpl viewIndex = viewIndexes.get(graph.getView());
if (viewIndex != null) {
graph.readLock();
try {
Iterator<T> iterator = null;
if (elementType.equals(Node.class)) {
iterator = (Iterator<T>) graph.getNodes().iterator();
} else if (elementType.equals(Edge.class)) {
iterator = (Iterator<T>) graph.getEdges().iterator();
}
if (iterator != null) {
while (iterator.hasNext()) {
Element element = iterator.next();
S set = getTimeSet(element);
if (set != null) {
K[] ts = set.toArray();
int tsLength = ts.length;
for (int i = 0; i < tsLength; i++) {
int timestamp = timeSortedMap.get(ts[i]);
viewIndex.add(timestamp, element);
}
}
}
}
} finally {
graph.readUnlock();
}
}
}
代码示例来源:origin: gephi/gephi-plugins-bootcamp
@Override
public void goAlgo() {
Graph graph = graphModel.getGraphVisible();
graph.readLock();
int nodeCount = graph.getNodeCount();
Node[] nodes = graph.getNodes().toArray();
int rows = (int) Math.round(Math.sqrt(nodeCount)) + 1;
int cols = (int) Math.round(Math.sqrt(nodeCount)) + 1;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols && (i * rows + j) < nodes.length; j++) {
Node node = nodes[i * rows + j];
float x = (-areaSize / 2f) + ((float) j / cols) * areaSize;
float y = (areaSize / 2f) - ((float) i / rows) * areaSize;
float px = node.x();
float py = node.y();
node.setX(px + (x - px) * (speed / 10000f));
node.setY(py + (y - py) * (speed / 10000f));
}
}
graph.readUnlock();
}
代码示例来源:origin: gephi/graphstore
public void indexView(Graph graph) {
TimeIndexImpl viewIndex = viewIndexes.get(graph.getView());
if (viewIndex != null) {
graph.readLock();
try {
Iterator<T> iterator = null;
if (elementType.equals(Node.class)) {
iterator = (Iterator<T>) graph.getNodes().iterator();
} else if (elementType.equals(Edge.class)) {
iterator = (Iterator<T>) graph.getEdges().iterator();
}
if (iterator != null) {
while (iterator.hasNext()) {
Element element = iterator.next();
S set = getTimeSet(element);
if (set != null) {
K[] ts = set.toArray();
int tsLength = ts.length;
for (int i = 0; i < tsLength; i++) {
int timestamp = timeSortedMap.get(ts[i]);
viewIndex.add(timestamp, element);
}
}
}
}
} finally {
graph.readUnlock();
}
}
}
代码示例来源:origin: gephi/graphstore
graph.readUnlock();
代码示例来源:origin: gephi/gephi-plugins-bootcamp
graph.readUnlock();
代码示例来源:origin: org.gephi/graphstore
graph.readUnlock();
代码示例来源:origin: org.gephi/statistics-plugin
public void execute(Graph graph) {
Column column = initializeAttributeColunms(graph.getModel());
int N = graph.getNodeCount();
graph.readLock();
try {
centralities = new double[N];
Progress.start(progress, numRuns);
HashMap<Integer, Node> indicies = new HashMap<>();
HashMap<Node, Integer> invIndicies = new HashMap<>();
fillIndiciesMaps(graph, centralities, indicies, invIndicies);
sumChange = calculateEigenvectorCentrality(graph, centralities, indicies, invIndicies, isDirected, numRuns);
saveCalculatedValues(graph, column, indicies, centralities);
} finally {
graph.readUnlock();
}
Progress.finish(progress);
}
代码示例来源:origin: org.gephi/statistics-plugin
graph.readUnlock();
代码示例来源:origin: gephi/gephi-plugins-bootcamp
graph.readUnlock();
内容来源于网络,如有侵权,请联系作者删除!