Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gs-algo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graphstream
gs-algo
Commits
6e51d63f
Commit
6e51d63f
authored
13 years ago
by
gsavin
Browse files
Options
Downloads
Patches
Plain Diff
Update DynamicAlgorithm javadoc.
parent
75bb52d3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/org/graphstream/algorithm/DynamicAlgorithm.java
+63
-12
63 additions, 12 deletions
src/org/graphstream/algorithm/DynamicAlgorithm.java
with
63 additions
and
12 deletions
src/org/graphstream/algorithm/DynamicAlgorithm.java
+
63
−
12
View file @
6e51d63f
...
...
@@ -31,21 +31,72 @@
package
org.graphstream.algorithm
;
/**
* Base for algorithms that can compute and maintain a property on a dynamic
* graph, during its evolution.
*
* <p>
* This is the same as the {@link org.graphstream.algorithm.Algorithm}
* interface, with the addition of methods to make the algorithm dynamic. The
* algorithm begins with a call to the
* {@link #init(org.graphstream.graph.Graph)} method and ends with a call to the
* {@link #terminate()} method. In between, the user must call
* {@link #compute()} in a loop, as long as the graph evolves.
* </p>
* Defines algorithms able to handle dynamics of a graph. This is an extension
* of the {@link org.graphstream.algorithm.Algorithm} so dynamic algorithms are
* composed of an initialization step followed by several computation steps. A
* last step, specific to dynamic algorithms, marks the termination of the
* algorithm and has to be used to close the computation.
*
* The following example computes the amount of apparitions of each node and the
* average value of apparitions for nodes :
*
* <pre>
* public class ApparitionAlgorithm extends SinkAdapter implements
* DynamicAlgorithm {
*
* Graph theGraph;
* HashMap<String, Integer> apparitions;
* double avg;
*
* public void init(Graph graph) {
* theGraph = graph;
* avg = 0;
* graph.addSink(this);
* }
*
* public void compute() {
* avg = 0;
*
* for (int a : apparitions.values())
* avg += a;
*
* avg /= apparitions.size();
* }
*
* public void terminate() {
* graph.removeSink(this);
* }
*
* public double getAverageApparitions() {
* return avg;
* }
*
* public int getApparitions(String nodeId) {
* return apparitions.get(nodeId);
* }
*
* public void nodeAdded(String sourceId, long timeId, String nodeId) {
* int a = 0;
*
* if (apparitions.containsKey(nodeId))
* a = apparitions.get(nodeId);
*
* apparitions.put(nodeId, a + 1);
* }
*
* public void stepBegins(String sourceId, long timeId, double step) {
* compute();
* }
* }
* </pre>
*
* Note that in the example, the #terminate() method is used to remove the link
* between graph and the algorithm. The computation here is done at every step
* but can be done anywhere else, according to the algorithm requirements.
*/
public
interface
DynamicAlgorithm
extends
Algorithm
{
/**
*
End
the dynamic algorithm.
*
Terminate
the dynamic algorithm.
*
* @see #init(org.graphstream.graph.Graph)
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment