Skip to content

Commit

Permalink
clean up readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs1998 committed Apr 26, 2022
1 parent 5b11a4b commit aa52a45
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 53 deletions.
144 changes: 91 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,91 @@
# A DAG in Java
# A `Dag` in Java

## How do I get it?

### Gradle package from GitHub Packages

```gradle
repositories {
mavenCentral()
maven {
url = uri('https://maven.pkg.github.com/ajs1998/Dag')
credentials {
username = 'ajs1998'
// This is a PAT (Personal Access Token) that only has permission to read/download public GitHub Packages.
// This is not the actual password for the account.
password = {YOUR GITHUB PAT}
}
}
}
```

```gradle
dependencies {
implementation 'me.alexjs:dag:1.10'
}
```

You need to <a href="https://github.com/settings/tokens">create a GitHub Personal Access Token (PAT)</a> to be able to
download GitHub Packages. The token only needs the `read:packages` permission to work.

### Maven Central package

Coming soon
## What is it?

## What can I do with it?

### Add nodes with (parent, child) relationships to the DAG

```java
Dag<String> dag = new HashDag<>();

// Add nodes with (parent, child) relationships to the DAG
dag.put("Dorothy", "Shelby");
dag.put("Shelby", "Alex");
dag.put("Joe", "Alex");
```

// Add individual nodes to the DAG
### Add individual nodes to the DAG

```java
dag.add("Clare");
dag.add("Sarah");
```

// Find a topologically sorted list of the nodes
// Ex: ["Sarah", "Clare", "Dorothy", "Joe", "Shelby", "Alex"]
### Find a topologically sorted list of the nodes

```java
List<String> sorted = dag.sort();
```

// Find the root nodes of the DAG
// Ex: ["Dorothy", "Joe", "Clare", "Sarah"]
Set<String> roots= dag.getRoots();
> `["Sarah", "Clare", "Dorothy", "Joe", "Shelby", "Alex"]`
// Find the leaf nodes of the DAG
// Ex: ["Alex", "Clare", "Sarah"]
### Find the root nodes of the DAG

```java
Set<String> roots = dag.getRoots();
```

> `["Dorothy", "Joe", "Clare", "Sarah"]`
### Find the leaf nodes of the DAG

```java
Set<String> leaves = dag.getLeaves();
```

> `["Alex", "Clare", "Sarah"]`
// Find the parents of a node
// Ex: ["Joe", "Shelby"]
### Find the parents of a node

```java
Set<String> parents = dag.getParents("Alex");
```

// Find the children of a node
// Ex: ["Shelby"]
> `["Joe", "Shelby"]`
### Find the children of a node

```java
Set<String> children = dag.getChildren("Dorothy");
```

> `["Shelby"]`
### Find the ancestors of a node

// Find the ancestors of a node
// Ex: ["Joe", "Shelby", "Dorothy"]
```java
Set<String> ancestors = dag.getAncestors("Alex");
```

> `["Joe", "Shelby", "Dorothy"]`
// Find the descendants of a node
// Ex: ["Shelby", "Alex"]
### Find the descendants of a node

```java
Set<String> descendants = dag.getDescendants("Dorothy");
```

// Get the Map representation of the DAG
> `["Shelby", "Alex"]`
### Get the Map representation of the DAG

```java
Map<String, Set<String>> map = dag.toMap();
```

### Create a shallow copy

// Create a shallow copy
```java
Dag<String> copy = dag.clone();
```

Expand All @@ -92,10 +100,40 @@ List<Integer> result = new LinkedList<>();
DagUtil.traverse(dag, i -> result.add(i), executorService);
```

## How do I get it?

### Gradle package from GitHub Packages

```gradle
repositories {
mavenCentral()
maven {
url = uri('https://maven.pkg.github.com/ajs1998/Dag')
credentials {
username = {YOUR GITHUB USERNAME}
// This is a PAT (Personal Access Token) that only has permission to read/download public GitHub Packages.
// This is not the actual password for the account.
password = {YOUR GITHUB PAT}
}
}
}
```

```gradle
dependencies {
implementation 'me.alexjs:dag:1.0.0'
}
```

You need to <a href="https://github.com/settings/tokens">create a GitHub Personal Access Token (PAT)</a> to be able to
download GitHub Packages. The token only needs the `read:packages` permission to work.

### Maven Central package

Coming soon

## Notes

- Flexible `Dag<T>` interface so you can write your own implementation
- 100% test coverage
- 100% Javadoc coverage
- I recommend using at least version `1.10`. Previous versions had little documentation, less test coverage, and fewer
features
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ repositories {
}

dependencies {

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'

}

test {
Expand Down

0 comments on commit aa52a45

Please sign in to comment.