Skip to content

Instantly share code, notes, and snippets.

Created December 24, 2012 03:32
Show Gist options
  • Save anonymous/4367332 to your computer and use it in GitHub Desktop.
Save anonymous/4367332 to your computer and use it in GitHub Desktop.
Graphs in Julia... some preliminary thoughts
module Chutes
abstract Graph
abstract DGraph <: Graph
abstract UGraph <: Graph
typealias LabelType Dict{Int,Any}
type DenseGraph <: Graph
mat :: Matrix{Uint8}
labels :: LabelType
count :: Int
end
DenseGraph(n::Int) = DenseGraph(zeros(Uint8,n,n), LabelType(), n)
addnode(g::DenseGraph, n::Int) = g.mat = hvcat((2,1), g.mat,TODO
addedge(g::DenseGraph, n1::Int, n2::Int) = (g.mat[n1,n2] = true)
delnode(g::DenseGraph, n::Int) = (g.count-=1; g.mat=g.mat[[1:k-1, k+1:end],:])
#deledge(
type DenseBitGraph <: Graph
mat :: BitMatrix
labels :: LabelType
count :: Int
end
DenseBitGraph(n::Int) = DenseBitGraph(falses(n,n), LabelType(), n)
type TableGraph <: Graph
mat :: Matrix{Int}
labels :: LabelType
count :: Int
end
TableGraph(n::Int) = TableGraph(zeros(Int,0,2), LabelType(), n)
#addnode(g::TableGraph, n::Int) =
#addedge(g::TableGraph, n1::Int, n2::Int) = g.mat
#delnode(g::TableGraph, n::Int) = (g.count-=1; g.mat=g.mat[[1:k-1, k+1:end],:])
#deledge(
end #module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment