Paste: dispatch error

Author: tsdh
Mode: lisp
Date: Fri, 4 Mar 2011 14:14:42
Plain Text |
;;** Access by seqs

(defn first-vertex
  "Gets the first vertex of graph g.
May be restricted by to class with :cls and exclude subclasses
with :exclude-subclasses."
  [g & {:keys [cls exclude-subclasses]
	:or {cls Vertex
	     exclude-subclasses false}}]
  (. g getFirstVertex cls exclude-subclasses))

(defn first-edge
  "Gets the first edge of graph g.
May be restricted by :cls."
  [g & {:keys [cls exclude-subclasses]
	:or {cls Edge
	     exclude-subclasses false}}]
  (. g getFirstEdge cls exclude-subclasses))

(defn next-vertex [v & {:keys [cls exclude-subclasses]
			:or {cls Vertex
			     exclude-subclasses false}}]
  (. v getNextVertex cls exclude-subclasses))

(defn next-edge [e & {:keys [cls exclude-subclasses]
		      :or {cls Edge
			   exclude-subclasses false}}]
  (. e getNextEdge cls exclude-subclasses))

(defn first-inc [v {:keys [cls dir exclude-subclasses]
		    :or {cls Vertex
			 dir EdgeDirection/INOUT
			 exclude-subclasses false}} ]
  (. v getFirstIncidence cls dir exclude-subclasses))

(defn next-inc [e {:keys [cls dir exclude-subclasses]
		   :or {cls Vertex
			dir EdgeDirection/INOUT
			exclude-subclasses false}}]
  (. e getNextIncidence cls dir exclude-subclasses))

;;** Vertex and Edge sequences

(defmulti vseq (fn [c & _] (class c)))

(defmethod vseq Graph
  [g & {:keys [cls exclude-subclasses]
	:or {cls Vertex
	     exclude-subclasses false}}]
  (let [f (first-vertex g :cls cls :exclude-subclasses exclude-subclasses)]
    (if f
      (vseq f :cls cls :exclude-subclasses exclude-subclasses)
      [])))

(defmethod vseq Vertex
  [v & {:keys [cls exclude-subclasses]
	:or {cls Vertex
	     exclude-subclasses false}}]
  (let [n (next-vertex v
		       :cls cls
		       :exclude-subclasses exclude-subclasses)]
    (concat [v]
	    (and n (lazy-seq (vseq n
				   :cls cls
				   :exclude-subclasses exclude-subclasses))))))

Annotation: nix

Author: tsdh
Mode: factor
Date: Fri, 4 Mar 2011 14:16:02
Plain Text |
(with-graph [g "/home/horn/uni/repos/tcp-state-extract-solution/input/medium-model.tg"] (take 10 (vseq g)))

New Annotation

Summary:
Author:
Mode:
Body: