Skip to content

Instantly share code, notes, and snippets.

@dsp
Created February 3, 2010 23:57
Show Gist options
  • Save dsp/294201 to your computer and use it in GitHub Desktop.
Save dsp/294201 to your computer and use it in GitHub Desktop.
(ns net.experimentalworks.clojure.outdegree
(:import
(edu.kit.ipd.sonar.server.centralities Centrality
Centrality$Type CentralityImpl)
(java.util HashMap))
(:gen-class
:extends edu.kit.ipd.sonar.server.centralities.CentralityImpl))
(defn -getType [this] Centrality$Type/NodeCentrality)
(defn -getName [this] "Outdegree (Clojure)")
(defn -getVersion [this] 1)
(defn -getRequiredAPIVersion [this] 0)
(defn -getWeight[this graph]
(let [nodes (.values (.getNodeList graph)) result (new HashMap)]
(doseq [node nodes]
(.put result node
(double
(count (filter #(.isOutgoingEdge % node) (.getEdgeList graph))))))
result)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment