|
26 | 26 | import java.util.function.Supplier;
|
27 | 27 | import java.util.stream.Collectors;
|
28 | 28 |
|
| 29 | +/* |
| 30 | + * MIT License |
| 31 | + * Copyright (c) 2016 Eduardo Ribeiro Rodrigues |
| 32 | + * |
| 33 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 34 | + * of this software and associated documentation files (the "Software"), to deal |
| 35 | + * in the Software without restriction, including without limitation the rights |
| 36 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 37 | + * copies of the Software, and to permit persons to whom the Software is |
| 38 | + * furnished to do so, subject to the following conditions: |
| 39 | + * |
| 40 | + * The above copyright notice and this permission notice shall be included in all |
| 41 | + * copies or substantial portions of the Software. |
| 42 | + * |
| 43 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 44 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 45 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 46 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 47 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 48 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 49 | + * SOFTWARE. |
| 50 | + */ |
| 51 | + |
29 | 52 | /**
|
30 | 53 | * <p>This class implements a dependency graph using a strongly connected
|
31 | 54 | * Directed Acyclic Graph (DAG) and allows sorting of its nodes in
|
32 | 55 | * topological order.</p>
|
33 | 56 | *
|
34 | 57 | * <p>Some important characteristics of this class are:</p>
|
35 |
| - * <ol><li>Calling {@link #getTopology} will not destroy the graph: |
36 |
| - * the same graph instance can be safely reused after a topological sort operation.</li> |
37 |
| - * <li>It can optionally be instantiated to be thread-safe (see {@link #DependencyGraph(boolean)}).</li> |
38 |
| - * <li>It is capable of detecting cycles (or circular dependencies paths) |
39 |
| - * and for each cycle list all participant nodes (see {@link #findCycles}).</li></ol> |
| 58 | + * <ol><li>The graph fully implements the {@link Collection} interface</li> |
| 59 | + * <li>Calling {@link #getTopology} will not destroy the graph: the same graph instance can be safely reused after a topological sort operation.</li> |
| 60 | + * <li>It can optionally be instantiated to be thread-safe (see {@link #DependencyGraph(boolean)}) adding some overhead due to use of {@link ReentrantReadWriteLock}s</li> |
| 61 | + * <li>It is capable of detecting cycles (or circular dependencies paths) and for each cycle list all participant nodes (see {@link #findCycles})</li></ol> |
40 | 62 | *
|
41 | 63 | * @param <T> The content type for the graph
|
| 64 | + * @author Eduardo Rodrigues (https://github.com/errodrigues/ez-graph) |
42 | 65 | */
|
| 66 | +//TODO: implement new method iteratePathsBetween(a, b) returning a standard Iterator where each next entry will be a Collection representing one valid path between nodes a and b |
43 | 67 | public final class DependencyGraph<T> implements Collection<T> {
|
44 | 68 | private static final Predicate<Object> IS_NULL = o -> o == null;
|
45 | 69 |
|
|
0 commit comments