Skip to content

Commit

Permalink
Add clean methods to delete attributes used by the algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibautDemare committed Mar 6, 2014
1 parent d4670a4 commit 658ee79
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/org/graphstream/algorithm/BetweennessCentrality.java
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,45 @@ protected void setupAllNodes(Graph graph) {
}
}

/**
* Delete attributes used by this algorithm in nodes and edges of the graph
*/
public void cleanGraph(){
cleanElement(graph.getEachEdge());
cleanElement(graph.getEachNode());
}

/**
* Delete attributes used by this algorithm in nodes of the graph
*/
public void cleanNodes(){
cleanElement(graph.getEachNode());
}

/**
* Delete attributes used by this algorithm in edges of the graph
*/
public void cleanEdges(){
cleanElement(graph.getEachEdge());
}

/**
* Delete attributes used by this algorithm in elements of a graph
* @param it the list of elements
*/
private void cleanElement(Iterable<? extends Element> it){
for(Element e : it){
if(e.hasAttribute(predAttributeName))
e.removeAttribute(predAttributeName);
if(e.hasAttribute(sigmaAttributeName))
e.removeAttribute(sigmaAttributeName);
if(e.hasAttribute(distAttributeName))
e.removeAttribute(distAttributeName);
if(e.hasAttribute(deltaAttributeName))
e.removeAttribute(deltaAttributeName);
}
}

/**
* Increasing comparator used for priority queues.
*/
Expand Down Expand Up @@ -841,4 +880,4 @@ public interface Progress {
*/
void progress(float percent);
}
}
}

0 comments on commit 658ee79

Please sign in to comment.