Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
michel2323 committed Feb 21, 2022
1 parent 96096f5 commit a555093
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@
This is the Julia interface to [ColPack](https://github.com/CSCsw/ColPack).

## Usage

### Read matrix market file
```julia
using ColPack
using MatrixMarket
coloring = ColPackColoring("m.mtx", ColPack.d1, "RANDOM")
println("Number of colors: ", length(unique(get_colors(coloring))))
println("Vector of vertex colors: ", get_colors(coloring))
```
### Pass the adjacency graph as a symmetric matrix of type `SparseMatrixCSC`
### Jacobian coloring by columns
```julia
using ColPack
using LinearAlgebra
using SparseArrays
A = convert(SparseMatrixCSC, Symmetric(sprand(100,100,0.1)))
coloring = ColPackColoring(A, ColPack.d1, "RANDOM")

# Example matrix/Jacobian
A = [
[1.0 1.0 0.0 0.0 0.0];
[0.0 0.0 1.0 0.0 0.0];
[0.0 1.0 0.0 1.0 0.0];
[0.0 0.0 0.0 1.0 1.0];
]

A = sparse(A)

# Create adjacency matrix for column coloring
adjA = ColPack.matrix2adjmatrix(A; partition_by_rows=false)

coloring = ColPackColoring(adjA, d1_coloring(), random_ordering())
println("Number of colors: ", length(unique(get_colors(coloring))))
println("Vector of vertex colors: ", get_colors(coloring))
```
Expand Down
7 changes: 7 additions & 0 deletions src/orderings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ struct distance_two_incidence_degree_ordering <: AbstractOrdering
end
distance_two_incidence_degree_ordering() = distance_two_incidence_degree_ordering("DISTANCE_TWO_INCIDENCE_DEGREE")

struct random_ordering <: AbstractOrdering
colpack_ordering::String
end
random_ordering() = random_ordering("RANDOM")

const ORDERINGS = [
distance_two_incidence_degree_ordering(),
distance_two_largest_first_ordering(),
Expand All @@ -47,8 +52,10 @@ const ORDERINGS = [
largest_first_ordering(),
natural_ordering(),
smallest_last_ordering(),
random_ordering(),
]

export natural_ordering, largest_first_ordering, dynamic_largest_first_ordering, distance_two_largest_first_ordering
export smallest_last_ordering, distance_two_smallest_last_ordering, incidence_degree_ordering, distance_two_incidence_degree_ordering
export random_ordering
export ORDERINGS

0 comments on commit a555093

Please sign in to comment.