Skip to content

Commit

Permalink
Merge pull request #27 from mofeing/new-functions
Browse files Browse the repository at this point in the history
Define `kahypar_set_seed`, `kahypar_validate_input`, `kahypar_read_hypergraph_from_file`
  • Loading branch information
jalving committed Nov 13, 2023
2 parents 46f721c + cc54596 commit a4f967f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/kahypar_h.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ function kahypar_context_free(context::Ref{kahypar_context_t})
context)
end

#Set seed
function kahypar_set_seed(context::Ref{kahypar_context_t}, seed)
ccall((:kahypar_set_seed,libkahypar), Cvoid, (Ref{kahypar_context_t}, Cint), context, seed)
end

#Set custom block weights
function kahypar_set_custom_target_block_weights(num_blocks::kahypar_hypernode_id_t,block_weights::Vector{kahypar_hypernode_weight_t},kahypar_context::Ref{kahypar_context_t})
ccall((:kahypar_set_custom_target_block_weights,libkahypar),
Expand Down Expand Up @@ -109,6 +114,27 @@ function kahypar_improve_partition(num_vertices, num_hyperedges, imbalance, num_
return
end

function kahypar_validate_input(num_vertices, num_hyperedges, hyperedge_indices, hyperedges, hyperedge_weights, vertex_weights, print_errors)
ccall((:kahypar_validate_input,libkahypar),
Cvoid,
(kahypar_hypernode_id_t,
kahypar_hyperedge_id_t,
Ref{Csize_t},
Ref{kahypar_hyperedge_id_t},
Ref{kahypar_hyperedge_weight_t},
Ref{kahypar_hypernode_weight_t},
Cint, # there is no Cbool type in Julia
),
num_vertices,
num_hyperedges,
hyperedge_indices,
hyperedges,
hyperedge_weights,
vertex_weights,
print_errors,
)
end

############################################################
#New interface functions that use a KaHyPar hypergraph type
#reference to the underlying C hypergraph type
Expand Down Expand Up @@ -147,6 +173,27 @@ function kahypar_create_hypergraph_from_file(filename::String,num_blocks::kahypa
return k_hypergraph
end

function kahypar_read_hypergraph_from_file(filename, num_vertices, num_hyperedges, hyperedge_indices, hyperedges, hyperedge_weights, vertex_weights)
ccall((:kahypar_read_hypergraph_from_file,libkahypar),
Cvoid,
(Cstring,
Ref{kahypar_hypernode_id_t},
Ref{kahypar_hyperedge_id_t},
Ptr{Ptr{Csize_t}},
Ptr{Ptr{kahypar_hyperedge_id_t}},
Ptr{Ptr{kahypar_hyperedge_weight_t}},
Ptr{Ptr{kahypar_hypernode_weight_t}},
),
filename,
num_vertices,
num_hyperedges,
hyperedge_indices,
hyperedges,
hyperedge_weights,
vertex_weights,
)
end

#Partition a hypergraph object
function kahypar_partition_hypergraph(k_hypergraph,num_blocks,imbalance,objective,context,partition)
ccall((:kahypar_partition_hypergraph,libkahypar),
Expand Down

0 comments on commit a4f967f

Please sign in to comment.