Created
February 3, 2010 23:57
-
-
Save dsp/294201 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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