├── .gitattributes
├── .gitignore
├── project.clj
├── README.md
├── pom.xml
├── src
└── main
│ └── clojure
│ └── clojure
│ └── algo
│ └── graph.clj
├── LICENSE
└── epl.html
/.gitattributes:
--------------------------------------------------------------------------------
1 | epl.html linguist-vendored=true
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .lein-failures
2 | *jar
3 | /lib/
4 | /classes/
5 | /target/
6 | .lein-deps-sum
7 |
--------------------------------------------------------------------------------
/project.clj:
--------------------------------------------------------------------------------
1 | (defproject algo.graph "0.1.0-SNAPSHOT"
2 | :description "Basic graph theory algorithms."
3 | :license {:name "Eclipse Public License"
4 | :url "http://www.eclipse.org/legal/epl-v10.html"}
5 |
6 | :global-vars {*warn-on-reflection* true}
7 |
8 | :repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
9 |
10 | :source-paths ["src/main/clojure"]
11 | :test-paths ["src/test/clojure"])
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # algo.graph
2 |
3 | Basic graph theory algorithms.
4 |
5 | # THIS PROJECT IS NO LONGER ACTIVE
6 |
7 | ## Releases and Dependency Information
8 |
9 | This project should be considered abandoned. No release was ever made.
10 |
11 | ## Documentation
12 |
13 | [API Reference](http://clojure.github.io/algo.graph/)
14 |
15 | ## Developer Information
16 |
17 | - [GitHub Project](https://github.com/clojure/algo.graph)
18 | - [Bug Tracker](http://dev.clojure.org/jira/browse/AGRAPH)
19 | - [Continuous Integration](http://build.clojure.org/job/algo.graph/)
20 | - [Compatibility Test Matrix](http://build.clojure.org/job/algo.graph-test-matrix/)
21 |
22 | ## Contributors
23 |
24 | * Jeffrey Straszheim
25 | * Tim Baldridge
26 |
27 | ## License
28 |
29 | Copyright © Jeffrey Straszheim, Rich Hickey & contributors.
30 |
31 | Licensed under the EPL (see the file epl.html).
32 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | algo.graph
5 | 0.1.0-SNAPSHOT
6 | algo.graph
7 | Basic graph theory algorithms.
8 |
9 |
10 |
11 | Eclipse Public License 1.0
12 | http://opensource.org/licenses/eclipse-1.0.php
13 | repo
14 |
15 |
16 |
17 |
18 | org.clojure
19 | pom.contrib
20 | 0.2.2
21 |
22 |
23 |
24 |
25 |
26 | com.theoryinpractise
27 | clojure-maven-plugin
28 | 1.7.1
29 |
30 | true
31 | true
32 | false
33 |
34 | clojure.algo.graph
35 |
36 |
37 | clojure.algo.graph
38 |
39 | true
40 |
41 | src/main/clojure
42 | src/test/clojure
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.clojure
52 | clojure
53 | 1.5.1
54 |
55 |
56 |
57 |
58 |
59 | hagari
60 | Timothy Baldridge
61 |
62 |
63 |
64 |
65 | scm:git:git://github.com/clojure/algo.graph.git
66 | scm:git:git://github.com/clojure/algo.graph.git
67 | http://github.com/clojure/algo.graph
68 | HEAD
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/src/main/clojure/clojure/algo/graph.clj:
--------------------------------------------------------------------------------
1 | ;; Copyright (c) Jeffrey Straszheim. All rights reserved. The use and
2 | ;; distribution terms for this software are covered by the Eclipse Public
3 | ;; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can
4 | ;; be found in the file epl-v10.html at the root of this distribution. By
5 | ;; using this software in any fashion, you are agreeing to be bound by the
6 | ;; terms of this license. You must not remove this notice, or any other,
7 | ;; from this software.
8 | ;;
9 | ;; graph
10 | ;;
11 | ;; Basic Graph Theory Algorithms
12 | ;;
13 | ;; straszheimjeffrey (gmail)
14 | ;; Created 23 June 2009
15 |
16 |
17 | (ns
18 | ^{:author "Jeffrey Straszheim",
19 | :doc "Basic graph theory algorithms"}
20 | clojure.algo.graph
21 | (use [clojure.set :only (union)]))
22 |
23 |
24 | (defstruct directed-graph
25 | :nodes ; The nodes of the graph, a collection
26 | :neighbors) ; A function that, given a node returns a collection
27 | ; neighbor nodes.
28 |
29 | (defn get-neighbors
30 | "Get the neighbors of a node."
31 | [g n]
32 | ((:neighbors g) n))
33 |
34 |
35 | ;; Graph Modification
36 |
37 | (defn reverse-graph
38 | "Given a directed graph, return another directed graph with the
39 | order of the edges reversed."
40 | [g]
41 | (let [op (fn [rna idx]
42 | (let [ns (get-neighbors g idx)
43 | am (fn [m val]
44 | (assoc m val (conj (get m val #{}) idx)))]
45 | (reduce am rna ns)))
46 | rn (reduce op {} (:nodes g))]
47 | (struct directed-graph (:nodes g) rn)))
48 |
49 | (defn add-loops
50 | "For each node n, add the edge n->n if not already present."
51 | [g]
52 | (struct directed-graph
53 | (:nodes g)
54 | (into {} (map (fn [n]
55 | [n (conj (set (get-neighbors g n)) n)]) (:nodes g)))))
56 |
57 | (defn remove-loops
58 | "For each node n, remove any edges n->n."
59 | [g]
60 | (struct directed-graph
61 | (:nodes g)
62 | (into {} (map (fn [n]
63 | [n (disj (set (get-neighbors g n)) n)]) (:nodes g)))))
64 |
65 |
66 | ;; Graph Walk
67 |
68 | (defn lazy-walk
69 | "Return a lazy sequence of the nodes of a graph starting a node n. Optionally,
70 | provide a set of visited notes (v) and a collection of nodes to
71 | visit (ns)."
72 | ([g n]
73 | (lazy-walk g [n] #{}))
74 | ([g ns v]
75 | (lazy-seq (let [s (seq (drop-while v ns))
76 | n (first s)
77 | ns (rest s)]
78 | (when s
79 | (cons n (lazy-walk g (concat (get-neighbors g n) ns) (conj v n))))))))
80 |
81 | (defn transitive-closure
82 | "Returns the transitive closure of a graph. The neighbors are lazily computed.
83 |
84 | Note: some version of this algorithm return all edges a->a
85 | regardless of whether such loops exist in the original graph. This
86 | version does not. Loops will be included only if produced by
87 | cycles in the graph. If you have code that depends on such
88 | behavior, call (-> g transitive-closure add-loops)"
89 | [g]
90 | (let [nns (fn [n]
91 | [n (delay (lazy-walk g (get-neighbors g n) #{}))])
92 | nbs (into {} (map nns (:nodes g)))]
93 | (struct directed-graph
94 | (:nodes g)
95 | (fn [n] (force (nbs n))))))
96 |
97 |
98 | ;; Strongly Connected Components
99 |
100 | (defn- post-ordered-visit
101 | "Starting at node n, perform a post-ordered walk."
102 | [g n [visited acc :as state]]
103 | (if (visited n)
104 | state
105 | (let [[v2 acc2] (reduce (fn [st nd] (post-ordered-visit g nd st))
106 | [(conj visited n) acc]
107 | (get-neighbors g n))]
108 | [v2 (conj acc2 n)])))
109 |
110 | (defn post-ordered-nodes
111 | "Return a sequence of indexes of a post-ordered walk of the graph."
112 | [g]
113 | (fnext (reduce #(post-ordered-visit g %2 %1)
114 | [#{} []]
115 | (:nodes g))))
116 |
117 | (defn scc
118 | "Returns, as a sequence of sets, the strongly connected components
119 | of g."
120 | [g]
121 | (let [po (reverse (post-ordered-nodes g))
122 | rev (reverse-graph g)
123 | step (fn [stack visited acc]
124 | (if (empty? stack)
125 | acc
126 | (let [[nv comp] (post-ordered-visit rev
127 | (first stack)
128 | [visited #{}])
129 | ns (remove nv stack)]
130 | (recur ns nv (conj acc comp)))))]
131 | (step po #{} [])))
132 |
133 | (defn component-graph
134 | "Given a graph, perhaps with cycles, return a reduced graph that is acyclic.
135 | Each node in the new graph will be a set of nodes from the old.
136 | These sets are the strongly connected components. Each edge will
137 | be the union of the corresponding edges of the prior graph."
138 | ([g]
139 | (component-graph g (scc g)))
140 | ([g sccs]
141 | (let [find-node-set (fn [n]
142 | (some #(if (% n) % nil) sccs))
143 | find-neighbors (fn [ns]
144 | (let [nbs1 (map (partial get-neighbors g) ns)
145 | nbs2 (map set nbs1)
146 | nbs3 (apply union nbs2)]
147 | (set (map find-node-set nbs3))))
148 | nm (into {} (map (fn [ns] [ns (find-neighbors ns)]) sccs))]
149 | (struct directed-graph (set sccs) nm))))
150 |
151 | (defn recursive-component?
152 | "Is the component (recieved from scc) self recursive?"
153 | [g ns]
154 | (or (> (count ns) 1)
155 | (let [n (first ns)]
156 | (some #(= % n) (get-neighbors g n)))))
157 |
158 | (defn self-recursive-sets
159 | "Returns, as a sequence of sets, the components of a graph that are
160 | self-recursive."
161 | [g]
162 | (filter (partial recursive-component? g) (scc g)))
163 |
164 |
165 | ;; Dependency Lists
166 |
167 | (defn fixed-point
168 | "Repeatedly apply fun to data until (equal old-data new-data)
169 | returns true. If max iterations occur, it will throw an
170 | exception. Set max to nil for unlimited iterations."
171 | [data fun max equal]
172 | (let [step (fn step [data idx]
173 | (when (and idx (= 0 idx))
174 | (throw (Exception. "Fixed point overflow")))
175 | (let [new-data (fun data)]
176 | (if (equal data new-data)
177 | new-data
178 | (recur new-data (and idx (dec idx))))))]
179 | (step data max)))
180 |
181 | (defn- fold-into-sets
182 | [priorities]
183 | (let [max (inc (apply max 0 (vals priorities)))
184 | step (fn [acc [n dep]]
185 | (assoc acc dep (conj (acc dep) n)))]
186 | (reduce step
187 | (vec (replicate max #{}))
188 | priorities)))
189 |
190 | (defn dependency-list
191 | "Similar to a topological sort, this returns a vector of sets. The
192 | set of nodes at index 0 are independent. The set at index 1 depend
193 | on index 0; those at 2 depend on 0 and 1, and so on. Those withing
194 | a set have no mutual dependencies. Assume the input graph (which
195 | much be acyclic) has an edge a->b when a depends on b."
196 | [g]
197 | (let [step (fn [d]
198 | (let [update (fn [n]
199 | (inc (apply max -1 (map d (get-neighbors g n)))))]
200 | (into {} (map (fn [[k v]] [k (update k)]) d))))
201 | counts (fixed-point (zipmap (:nodes g) (repeat 0))
202 | step
203 | (inc (count (:nodes g)))
204 | =)]
205 | (fold-into-sets counts)))
206 |
207 | (defn stratification-list
208 | "Similar to dependency-list (see doc), except two graphs are
209 | provided. The first is as dependency-list. The second (which may
210 | have cycles) provides a partial-dependency relation. If node a
211 | depends on node b (meaning an edge a->b exists) in the second
212 | graph, node a must be equal or later in the sequence."
213 | [g1 g2]
214 | (assert (= (-> g1 :nodes set) (-> g2 :nodes set)))
215 | (let [step (fn [d]
216 | (let [update (fn [n]
217 | (max (inc (apply max -1
218 | (map d (get-neighbors g1 n))))
219 | (apply max -1 (map d (get-neighbors g2 n)))))]
220 | (into {} (map (fn [[k v]] [k (update k)]) d))))
221 | counts (fixed-point (zipmap (:nodes g1) (repeat 0))
222 | step
223 | (inc (count (:nodes g1)))
224 | =)]
225 | (fold-into-sets counts)))
226 |
227 |
228 | ;; End of file
229 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 1.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6 |
7 | 1. DEFINITIONS
8 |
9 | "Contribution" means:
10 |
11 | a) in the case of the initial Contributor, the initial code and documentation
12 | distributed under this Agreement, and
13 | b) in the case of each subsequent Contributor:
14 | i) changes to the Program, and
15 | ii) additions to the Program;
16 |
17 | where such changes and/or additions to the Program originate from and are
18 | distributed by that particular Contributor. A Contribution 'originates' from
19 | a Contributor if it was added to the Program by such Contributor itself or
20 | anyone acting on such Contributor's behalf. Contributions do not include
21 | additions to the Program which: (i) are separate modules of software
22 | distributed in conjunction with the Program under their own license
23 | agreement, and (ii) are not derivative works of the Program.
24 |
25 | "Contributor" means any person or entity that distributes the Program.
26 |
27 | "Licensed Patents" mean patent claims licensable by a Contributor which are
28 | necessarily infringed by the use or sale of its Contribution alone or when
29 | combined with the Program.
30 |
31 | "Program" means the Contributions distributed in accordance with this Agreement.
32 |
33 | "Recipient" means anyone who receives the Program under this Agreement,
34 | including all Contributors.
35 |
36 | 2. GRANT OF RIGHTS
37 | a) Subject to the terms of this Agreement, each Contributor hereby grants
38 | Recipient a non-exclusive, worldwide, royalty-free copyright license to
39 | reproduce, prepare derivative works of, publicly display, publicly perform,
40 | distribute and sublicense the Contribution of such Contributor, if any, and
41 | such derivative works, in source code and object code form.
42 | b) Subject to the terms of this Agreement, each Contributor hereby grants
43 | Recipient a non-exclusive, worldwide, royalty-free patent license under
44 | Licensed Patents to make, use, sell, offer to sell, import and otherwise
45 | transfer the Contribution of such Contributor, if any, in source code and
46 | object code form. This patent license shall apply to the combination of the
47 | Contribution and the Program if, at the time the Contribution is added by
48 | the Contributor, such addition of the Contribution causes such combination
49 | to be covered by the Licensed Patents. The patent license shall not apply
50 | to any other combinations which include the Contribution. No hardware per
51 | se is licensed hereunder.
52 | c) Recipient understands that although each Contributor grants the licenses to
53 | its Contributions set forth herein, no assurances are provided by any
54 | Contributor that the Program does not infringe the patent or other
55 | intellectual property rights of any other entity. Each Contributor
56 | disclaims any liability to Recipient for claims brought by any other entity
57 | based on infringement of intellectual property rights or otherwise. As a
58 | condition to exercising the rights and licenses granted hereunder, each
59 | Recipient hereby assumes sole responsibility to secure any other
60 | intellectual property rights needed, if any. For example, if a third party
61 | patent license is required to allow Recipient to distribute the Program, it
62 | is Recipient's responsibility to acquire that license before distributing
63 | the Program.
64 | d) Each Contributor represents that to its knowledge it has sufficient
65 | copyright rights in its Contribution, if any, to grant the copyright
66 | license set forth in this Agreement.
67 |
68 | 3. REQUIREMENTS
69 |
70 | A Contributor may choose to distribute the Program in object code form under its
71 | own license agreement, provided that:
72 |
73 | a) it complies with the terms and conditions of this Agreement; and
74 | b) its license agreement:
75 | i) effectively disclaims on behalf of all Contributors all warranties and
76 | conditions, express and implied, including warranties or conditions of
77 | title and non-infringement, and implied warranties or conditions of
78 | merchantability and fitness for a particular purpose;
79 | ii) effectively excludes on behalf of all Contributors all liability for
80 | damages, including direct, indirect, special, incidental and
81 | consequential damages, such as lost profits;
82 | iii) states that any provisions which differ from this Agreement are offered
83 | by that Contributor alone and not by any other party; and
84 | iv) states that source code for the Program is available from such
85 | Contributor, and informs licensees how to obtain it in a reasonable
86 | manner on or through a medium customarily used for software exchange.
87 |
88 | When the Program is made available in source code form:
89 |
90 | a) it must be made available under this Agreement; and
91 | b) a copy of this Agreement must be included with each copy of the Program.
92 | Contributors may not remove or alter any copyright notices contained within
93 | the Program.
94 |
95 | Each Contributor must identify itself as the originator of its Contribution, if
96 | any, in a manner that reasonably allows subsequent Recipients to identify the
97 | originator of the Contribution.
98 |
99 | 4. COMMERCIAL DISTRIBUTION
100 |
101 | Commercial distributors of software may accept certain responsibilities with
102 | respect to end users, business partners and the like. While this license is
103 | intended to facilitate the commercial use of the Program, the Contributor who
104 | includes the Program in a commercial product offering should do so in a manner
105 | which does not create potential liability for other Contributors. Therefore, if
106 | a Contributor includes the Program in a commercial product offering, such
107 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
108 | every other Contributor ("Indemnified Contributor") against any losses, damages
109 | and costs (collectively "Losses") arising from claims, lawsuits and other legal
110 | actions brought by a third party against the Indemnified Contributor to the
111 | extent caused by the acts or omissions of such Commercial Contributor in
112 | connection with its distribution of the Program in a commercial product
113 | offering. The obligations in this section do not apply to any claims or Losses
114 | relating to any actual or alleged intellectual property infringement. In order
115 | to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
116 | Contributor in writing of such claim, and b) allow the Commercial Contributor to
117 | control, and cooperate with the Commercial Contributor in, the defense and any
118 | related settlement negotiations. The Indemnified Contributor may participate in
119 | any such claim at its own expense.
120 |
121 | For example, a Contributor might include the Program in a commercial product
122 | offering, Product X. That Contributor is then a Commercial Contributor. If that
123 | Commercial Contributor then makes performance claims, or offers warranties
124 | related to Product X, those performance claims and warranties are such
125 | Commercial Contributor's responsibility alone. Under this section, the
126 | Commercial Contributor would have to defend claims against the other
127 | Contributors related to those performance claims and warranties, and if a court
128 | requires any other Contributor to pay any damages as a result, the Commercial
129 | Contributor must pay those damages.
130 |
131 | 5. NO WARRANTY
132 |
133 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
134 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
135 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
136 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
137 | Recipient is solely responsible for determining the appropriateness of using and
138 | distributing the Program and assumes all risks associated with its exercise of
139 | rights under this Agreement , including but not limited to the risks and costs
140 | of program errors, compliance with applicable laws, damage to or loss of data,
141 | programs or equipment, and unavailability or interruption of operations.
142 |
143 | 6. DISCLAIMER OF LIABILITY
144 |
145 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
146 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
147 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
148 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
149 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
150 | OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
151 | GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
152 |
153 | 7. GENERAL
154 |
155 | If any provision of this Agreement is invalid or unenforceable under applicable
156 | law, it shall not affect the validity or enforceability of the remainder of the
157 | terms of this Agreement, and without further action by the parties hereto, such
158 | provision shall be reformed to the minimum extent necessary to make such
159 | provision valid and enforceable.
160 |
161 | If Recipient institutes patent litigation against any entity (including a
162 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself
163 | (excluding combinations of the Program with other software or hardware)
164 | infringes such Recipient's patent(s), then such Recipient's rights granted under
165 | Section 2(b) shall terminate as of the date such litigation is filed.
166 |
167 | All Recipient's rights under this Agreement shall terminate if it fails to
168 | comply with any of the material terms or conditions of this Agreement and does
169 | not cure such failure in a reasonable period of time after becoming aware of
170 | such noncompliance. If all Recipient's rights under this Agreement terminate,
171 | Recipient agrees to cease use and distribution of the Program as soon as
172 | reasonably practicable. However, Recipient's obligations under this Agreement
173 | and any licenses granted by Recipient relating to the Program shall continue and
174 | survive.
175 |
176 | Everyone is permitted to copy and distribute copies of this Agreement, but in
177 | order to avoid inconsistency the Agreement is copyrighted and may only be
178 | modified in the following manner. The Agreement Steward reserves the right to
179 | publish new versions (including revisions) of this Agreement from time to time.
180 | No one other than the Agreement Steward has the right to modify this Agreement.
181 | The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation
182 | may assign the responsibility to serve as the Agreement Steward to a suitable
183 | separate entity. Each new version of the Agreement will be given a
184 | distinguishing version number. The Program (including Contributions) may always
185 | be distributed subject to the version of the Agreement under which it was
186 | received. In addition, after a new version of the Agreement is published,
187 | Contributor may elect to distribute the Program (including its Contributions)
188 | under the new version. Except as expressly stated in Sections 2(a) and 2(b)
189 | above, Recipient receives no rights or licenses to the intellectual property of
190 | any Contributor under this Agreement, whether expressly, by implication,
191 | estoppel or otherwise. All rights in the Program not expressly granted under
192 | this Agreement are reserved.
193 |
194 | This Agreement is governed by the laws of the State of New York and the
195 | intellectual property laws of the United States of America. No party to this
196 | Agreement will bring a legal action under this Agreement more than one year
197 | after the cause of action arose. Each party waives its rights to a jury trial in
198 | any resulting litigation.
199 |
--------------------------------------------------------------------------------
/epl.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Eclipse Public License - Version 1.0
8 |
25 |
26 |
27 |
28 |
29 |
30 | Eclipse Public License - v 1.0
31 |
32 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
33 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
34 | DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
35 | AGREEMENT.
36 |
37 | 1. DEFINITIONS
38 |
39 | "Contribution" means:
40 |
41 | a) in the case of the initial Contributor, the initial
42 | code and documentation distributed under this Agreement, and
43 | b) in the case of each subsequent Contributor:
44 | i) changes to the Program, and
45 | ii) additions to the Program;
46 | where such changes and/or additions to the Program
47 | originate from and are distributed by that particular Contributor. A
48 | Contribution 'originates' from a Contributor if it was added to the
49 | Program by such Contributor itself or anyone acting on such
50 | Contributor's behalf. Contributions do not include additions to the
51 | Program which: (i) are separate modules of software distributed in
52 | conjunction with the Program under their own license agreement, and (ii)
53 | are not derivative works of the Program.
54 |
55 | "Contributor" means any person or entity that distributes
56 | the Program.
57 |
58 | "Licensed Patents" mean patent claims licensable by a
59 | Contributor which are necessarily infringed by the use or sale of its
60 | Contribution alone or when combined with the Program.
61 |
62 | "Program" means the Contributions distributed in accordance
63 | with this Agreement.
64 |
65 | "Recipient" means anyone who receives the Program under
66 | this Agreement, including all Contributors.
67 |
68 | 2. GRANT OF RIGHTS
69 |
70 | a) Subject to the terms of this Agreement, each
71 | Contributor hereby grants Recipient a non-exclusive, worldwide,
72 | royalty-free copyright license to reproduce, prepare derivative works
73 | of, publicly display, publicly perform, distribute and sublicense the
74 | Contribution of such Contributor, if any, and such derivative works, in
75 | source code and object code form.
76 |
77 | b) Subject to the terms of this Agreement, each
78 | Contributor hereby grants Recipient a non-exclusive, worldwide,
79 | royalty-free patent license under Licensed Patents to make, use, sell,
80 | offer to sell, import and otherwise transfer the Contribution of such
81 | Contributor, if any, in source code and object code form. This patent
82 | license shall apply to the combination of the Contribution and the
83 | Program if, at the time the Contribution is added by the Contributor,
84 | such addition of the Contribution causes such combination to be covered
85 | by the Licensed Patents. The patent license shall not apply to any other
86 | combinations which include the Contribution. No hardware per se is
87 | licensed hereunder.
88 |
89 | c) Recipient understands that although each Contributor
90 | grants the licenses to its Contributions set forth herein, no assurances
91 | are provided by any Contributor that the Program does not infringe the
92 | patent or other intellectual property rights of any other entity. Each
93 | Contributor disclaims any liability to Recipient for claims brought by
94 | any other entity based on infringement of intellectual property rights
95 | or otherwise. As a condition to exercising the rights and licenses
96 | granted hereunder, each Recipient hereby assumes sole responsibility to
97 | secure any other intellectual property rights needed, if any. For
98 | example, if a third party patent license is required to allow Recipient
99 | to distribute the Program, it is Recipient's responsibility to acquire
100 | that license before distributing the Program.
101 |
102 | d) Each Contributor represents that to its knowledge it
103 | has sufficient copyright rights in its Contribution, if any, to grant
104 | the copyright license set forth in this Agreement.
105 |
106 | 3. REQUIREMENTS
107 |
108 | A Contributor may choose to distribute the Program in object code
109 | form under its own license agreement, provided that:
110 |
111 | a) it complies with the terms and conditions of this
112 | Agreement; and
113 |
114 | b) its license agreement:
115 |
116 | i) effectively disclaims on behalf of all Contributors
117 | all warranties and conditions, express and implied, including warranties
118 | or conditions of title and non-infringement, and implied warranties or
119 | conditions of merchantability and fitness for a particular purpose;
120 |
121 | ii) effectively excludes on behalf of all Contributors
122 | all liability for damages, including direct, indirect, special,
123 | incidental and consequential damages, such as lost profits;
124 |
125 | iii) states that any provisions which differ from this
126 | Agreement are offered by that Contributor alone and not by any other
127 | party; and
128 |
129 | iv) states that source code for the Program is available
130 | from such Contributor, and informs licensees how to obtain it in a
131 | reasonable manner on or through a medium customarily used for software
132 | exchange.
133 |
134 | When the Program is made available in source code form:
135 |
136 | a) it must be made available under this Agreement; and
137 |
138 | b) a copy of this Agreement must be included with each
139 | copy of the Program.
140 |
141 | Contributors may not remove or alter any copyright notices contained
142 | within the Program.
143 |
144 | Each Contributor must identify itself as the originator of its
145 | Contribution, if any, in a manner that reasonably allows subsequent
146 | Recipients to identify the originator of the Contribution.
147 |
148 | 4. COMMERCIAL DISTRIBUTION
149 |
150 | Commercial distributors of software may accept certain
151 | responsibilities with respect to end users, business partners and the
152 | like. While this license is intended to facilitate the commercial use of
153 | the Program, the Contributor who includes the Program in a commercial
154 | product offering should do so in a manner which does not create
155 | potential liability for other Contributors. Therefore, if a Contributor
156 | includes the Program in a commercial product offering, such Contributor
157 | ("Commercial Contributor") hereby agrees to defend and
158 | indemnify every other Contributor ("Indemnified Contributor")
159 | against any losses, damages and costs (collectively "Losses")
160 | arising from claims, lawsuits and other legal actions brought by a third
161 | party against the Indemnified Contributor to the extent caused by the
162 | acts or omissions of such Commercial Contributor in connection with its
163 | distribution of the Program in a commercial product offering. The
164 | obligations in this section do not apply to any claims or Losses
165 | relating to any actual or alleged intellectual property infringement. In
166 | order to qualify, an Indemnified Contributor must: a) promptly notify
167 | the Commercial Contributor in writing of such claim, and b) allow the
168 | Commercial Contributor to control, and cooperate with the Commercial
169 | Contributor in, the defense and any related settlement negotiations. The
170 | Indemnified Contributor may participate in any such claim at its own
171 | expense.
172 |
173 | For example, a Contributor might include the Program in a commercial
174 | product offering, Product X. That Contributor is then a Commercial
175 | Contributor. If that Commercial Contributor then makes performance
176 | claims, or offers warranties related to Product X, those performance
177 | claims and warranties are such Commercial Contributor's responsibility
178 | alone. Under this section, the Commercial Contributor would have to
179 | defend claims against the other Contributors related to those
180 | performance claims and warranties, and if a court requires any other
181 | Contributor to pay any damages as a result, the Commercial Contributor
182 | must pay those damages.
183 |
184 | 5. NO WARRANTY
185 |
186 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
187 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
188 | OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
189 | ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
190 | OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
191 | responsible for determining the appropriateness of using and
192 | distributing the Program and assumes all risks associated with its
193 | exercise of rights under this Agreement , including but not limited to
194 | the risks and costs of program errors, compliance with applicable laws,
195 | damage to or loss of data, programs or equipment, and unavailability or
196 | interruption of operations.
197 |
198 | 6. DISCLAIMER OF LIABILITY
199 |
200 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
201 | NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
202 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
203 | WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
204 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
205 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
206 | DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
207 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
208 |
209 | 7. GENERAL
210 |
211 | If any provision of this Agreement is invalid or unenforceable under
212 | applicable law, it shall not affect the validity or enforceability of
213 | the remainder of the terms of this Agreement, and without further action
214 | by the parties hereto, such provision shall be reformed to the minimum
215 | extent necessary to make such provision valid and enforceable.
216 |
217 | If Recipient institutes patent litigation against any entity
218 | (including a cross-claim or counterclaim in a lawsuit) alleging that the
219 | Program itself (excluding combinations of the Program with other
220 | software or hardware) infringes such Recipient's patent(s), then such
221 | Recipient's rights granted under Section 2(b) shall terminate as of the
222 | date such litigation is filed.
223 |
224 | All Recipient's rights under this Agreement shall terminate if it
225 | fails to comply with any of the material terms or conditions of this
226 | Agreement and does not cure such failure in a reasonable period of time
227 | after becoming aware of such noncompliance. If all Recipient's rights
228 | under this Agreement terminate, Recipient agrees to cease use and
229 | distribution of the Program as soon as reasonably practicable. However,
230 | Recipient's obligations under this Agreement and any licenses granted by
231 | Recipient relating to the Program shall continue and survive.
232 |
233 | Everyone is permitted to copy and distribute copies of this
234 | Agreement, but in order to avoid inconsistency the Agreement is
235 | copyrighted and may only be modified in the following manner. The
236 | Agreement Steward reserves the right to publish new versions (including
237 | revisions) of this Agreement from time to time. No one other than the
238 | Agreement Steward has the right to modify this Agreement. The Eclipse
239 | Foundation is the initial Agreement Steward. The Eclipse Foundation may
240 | assign the responsibility to serve as the Agreement Steward to a
241 | suitable separate entity. Each new version of the Agreement will be
242 | given a distinguishing version number. The Program (including
243 | Contributions) may always be distributed subject to the version of the
244 | Agreement under which it was received. In addition, after a new version
245 | of the Agreement is published, Contributor may elect to distribute the
246 | Program (including its Contributions) under the new version. Except as
247 | expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
248 | rights or licenses to the intellectual property of any Contributor under
249 | this Agreement, whether expressly, by implication, estoppel or
250 | otherwise. All rights in the Program not expressly granted under this
251 | Agreement are reserved.
252 |
253 | This Agreement is governed by the laws of the State of New York and
254 | the intellectual property laws of the United States of America. No party
255 | to this Agreement will bring a legal action under this Agreement more
256 | than one year after the cause of action arose. Each party waives its
257 | rights to a jury trial in any resulting litigation.
258 |
259 |
260 |
261 |
262 |
--------------------------------------------------------------------------------