Scotch
Documentation for Scotch.
The official SCOTCH user manual is referenced everywhere is this documentation. You can get the manual from the official GitLab.
Any SCOTCH function of the C library used within the wrapper is mentioned here. Therefore you can search any SCOTCH function from this page to know what its Julia equivalent is.
All names starting with SCOTCH_ are part of the C library. You can access all symbols defined in the C library through Scotch.LibScotch.
Scotch.Scotch — ModuleScotchWrapper for the SCOTCH graph partitionning library.
The official SCOTCH user manual is referenced everywhere is this documentation. You can get the user manual from the official GitLab.
Strategy
Scotch.Strat — TypeStratWrapper around a SCOTCH_Strat pointer.
Scotch.strat_alloc — Functionstrat_alloc()Allocate a new Strat with SCOTCH_stratAlloc, then initialize it with SCOTCH_stratInit.
Finalizers will properly call SCOTCH_stratExit then SCOTCH_memFree once unused.
Scotch.strat_flags — Functionstrat_flags(; strategy=:default,
recursive=false, remap=false,
disconnected=false, level_max=false, level_min=false, leaf_simple=false, sepa_simple=false
)Return a flag value (mentionned as flagval in the SCOTCH manual) depending on the given flags.
Available straegies are: :default, :balance, :quality, :safety and :speed.
See the section 8.3.1 of the manual for their corresponding meaning.
Scotch.strat — Functionstrat(type::Symbol, strategy::AbstractString)Allocate and initialize a new Strat from the given strategy string.
type is the strategy type:
:graph_bipartusesSCOTCH_stratGraphBipart:graph_mapusesSCOTCH_stratGraphMap:graph_part_overlapusesSCOTCH_stratGraphPartOvl:graph_orderusesSCOTCH_stratGraphOrder:mesh_orderusesSCOTCH_stratMeshOrder
Scotch.strat_build — Functionstrat_build(type::Symbol;
imbalance_ratio::Float64=0.0, parts=0,
max_cluster_weight=0, min_edge_density=0.0, level_nbr=0,
strategy=:default, kwargs...
)Allocate and initialize a new Strat from the given parameters. Not all of them are used for every type, see the manual for more info.
strategy and kwargs are passed to strat_flags.
type is the strategy type:
:implicituses the default strategy of the next call of any SCOTCH function requiring a strategy. Note that theStratwill keep the same strategy afterwards.:graph_clusterusesSCOTCH_stratGraphClusterBuild. Relies onmax_cluster_weight,min_edge_densityandimbalance_ratio.:graph_mapusesSCOTCH_stratGraphMapBuild. Relies onpartsandimbalance_ratio.:graph_part_overlapusesSCOTCH_stratGraphPartOvlBuild. Relies onpartsandimbalance_ratio.:graph_orderusesSCOTCH_stratGraphOrderBuild. Relies onlevel_nbrandimbalance_ratio.:mesh_orderusesSCOTCH_stratMeshOrderBuild. Relies onimbalance_ratio.
Architecture
Scotch.Arch — TypeArchWrapper around a SCOTCH_Arch pointer.
Scotch.arch_alloc — Functionarch_alloc()Allocate a new Arch with SCOTCH_archAlloc, then initialize it with SCOTCH_archInit.
Finalizers will properly call SCOTCH_archExit then SCOTCH_memFree once unused.
Scotch.arch_load — Functionarch_load(filename::AbstractString)
arch_load(file::IO)Load a new Arch from the given file. See SCOTCH_archLoad.
Scotch.arch_size — Functionarch_size(arch::Arch)Number of nodes in arch. See SCOTCH_archSize.
Scotch.arch_name — Functionarch_name(arch::Arch)Name of arch. See SCOTCH_archName.
Scotch.is_arch_variable — Functionis_arch_variable(arch::Arch)true if arch has a variable size.
Scotch.arch_build — Functionarch_build(graph::Graph; restrain=nothing)Allocate and initialize a new Arch with SCOTCH_archBuild2.
restrain may be a Vector{SCOTCH_Num} of indices of graph nodes.
arch_build(graph::Graph, strat::Strat; target=:default, restrain=nothing)Allocate and initialize a new Arch using strategy for the given target:
:defaultusesSCOTCH_archBuild:deco_1usesSCOTCH_archBuild0:deco_2usesSCOTCH_archBuild2
restrain may be a Vector{SCOTCH_Num} of indices of graph nodes.
Scotch.arch_complete_graph — Functionarch_complete_graph(n_vertices; weights=nothing, variable=false)Allocate and initialize a new Arch for a complete graph topology with SCOTCH_archCmplt, SCOTCH_archCmpltw or SCOTCH_archVcmplt.
Scotch.arch_hypercube — Functionarch_hypercube(dim; variable=false)Allocate and initialize a new Arch for a hypercube topology with SCOTCH_archHcub or SCOTCH_archVhcub.
Scotch.arch_mesh — Functionarch_mesh(dimensions::Vector{SCOTCH_Num})Allocate and initialize a new Arch for a mesh topology with SCOTCH_archMeshX.
Scotch.arch_torus — Functionarch_torus(dimensions::Vector{SCOTCH_Num})Allocate and initialize a new Arch for a torus topology with SCOTCH_archTorusX.
Scotch.arch_tree — Functionarch_tree(levels::Vector{SCOTCH_Num}, link_cost::Vector{SCOTCH_Num})Allocate and initialize a new Arch for a tree topology with SCOTCH_archTleaf.
The tree has length(levels) levels (excluding the leafs), each of them with levels[i] children per level node, and a link cost to the parent node of link_cost[i].
Scotch.arch_subset — Functionarch_subset(arch::Arch, processors::Vector{SCOTCH_Num}; one_index=true)Allocate and initialize a new Arch from a subset of arch including processors with SCOTCH_archSub.
If one_index == true, processors are 1-based indices to the processors in the parent arch, otherwise they are 0-based and no conversion is done.
The resulting sub_arch keeps a reference to the parent arch, to prevent it from being deallocated.
Graph
Scotch.Graph — TypeGraphWrapper around a SCOTCH_Graph pointer.
References to the arrays which may have been used to build the graph are stored in the struct, preventing them from being GC'ed by Julia.
Scotch.graph_alloc — Functiongraph_alloc()Allocate a new Graph with SCOTCH_graphAlloc, then initialize it with SCOTCH_graphInit.
Finalizers will properly call SCOTCH_graphExit then SCOTCH_memFree once unused.
Scotch.graph_size — Functiongraph_size(graph::Graph)Number of vertices and edges (arcs) of the graph.
Scotch.graph_build — Functiongraph_build(
adj_index::Vector{SCOTCH_Num}, adj_array::Vector{SCOTCH_Num};
index_start=1, check=true,
adj_idx_end::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
v_weights::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
e_weights::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
labels::Union{Vector{SCOTCH_Num}, Nothing}=nothing
)Allocate and initialize a new Graph using SCOTCH_graphBuild.
If check == true, then SCOTCH_graphCheck may throw an error if the graph is invalid.
If adj_idx_end is given, adj_index is considered to be non-compact.
Scotch.graph_base_index — Functiongraph_base_index(graph::Graph)Return the base index of graph, using SCOTCH_graphData.
Scotch.graph_base_index! — Functiongraph_base_index!(graph::Graph, base_idx)Sets the base index of graph using SCOTCH_graphBase
Scotch.graph_data — Functiongraph_data(graph::Graph)Returns a NamedTuple containing:
(;
index_start, n_vertices, n_arcs, n_edges,
adj_idx, adj_idx_end, vertices_weights,
vertices_labels, adj_array, arcs_weights
)Arrays are either nothing or wrapped into a Vector{SCOTCH_Num}. They share the data with the underlying graph.
Scotch.graph_dump — Functiongraph_dump(graph::Graph, filename::AbstractString, name_prefix::AbstractString, name_suffix::AbstractString)Use SCOTCH_graphDump to dump the graph to filename.
Scotch.graph_load — Functiongraph_load(file::IO; index_start=nothing, vertex_weights=true, edge_weights=true)
graph_load(filename::AbstractString; kwargs...)Load a new Graph from file with SCOTCH_graphLoad.
If index_start == nothing, then the base indexing of the file is conserved.
Scotch.graph_coarsen — Functiongraph_coarsen(fine_graph::Graph, n_vertices, coarsening_ratio;
no_merge=false, coarse_multi_nodes::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
fine_mates::Union{Vector{SCOTCH_Num}, Nothing}=nothing
)Coarsen fine_graph into a new Graph with n_vertices at maximum. Returns (coarse_graph, coarse_multi_nodes), or (nothing, nothing) if the coarsening failed.
no_merge sets the SCOTCH_COARSENNOMERGE flag.
If fine_mates is given, SCOTCH_graphCoarsenBuild is used, SCOTCH_graphCoarsen otherwise.
Scotch.graph_coarsen_match — Functiongraph_coarsen_match(fine_graph::Graph, n_vertices, coarsening_ratio;
no_merge=false, fine_mates::Union{Vector{SCOTCH_Num}, Nothing}=nothing
)Fill fine_mates using SCOTCH_graphCoarsenMatch. Returns (n_vertices, fine_mates), or (nothing, nothing) if the coarsening failed.
no_merge sets the SCOTCH_COARSENNOMERGE flag.
Scotch.graph_color — Functiongraph_color(graph::Graph; colors::Union{Vector{SCOTCH_Num}, Nothing}=nothing)Compute a coloring of the graph using SCOTCH_graphColor. Returns (n_colors, colors).
Scotch.graph_diameter — Functiongraph_diameter(graph::Graph)Diameter of the graph, using SCOTCH_graphDiamPV.
Scotch.graph_induce — Functiongraph_induce(graph::Graph, keep_vertices::Vector{SCOTCH_Num})A new [Graph] induced from graph by keeping the vertices in keep_vertices, using SCOTCH_graphInduceList.
graph_induce(graph::Graph, vertices_part::Vector{SCOTCH_GraphPart2}, keep_part::SCOTCH_GraphPart2)A new [Graph] induced from graph by keeping the vertices for which vertices_part matches keep_part, using SCOTCH_graphInducePart.
Scotch.graph_stat — Functiongraph_stat(graph::Graph)Statistics about the graph: returns (; vertex_load, edge_load, vertex_degree). Each value contains the following fields: min, max, sum (not for vertex_degree), avg (average) and var (standard deviation).
Mapping and partitioning
Scotch.graph_map — Functiongraph_map(graph::Graph, arch::Arch, strat::Strat; partition=nothing, fixed=false)Map graph to arch with strat using SCOTCH_graphMap. Returns partition, with indices starting from 0.
If fixed == true, then partition (0-index) gives the fixed vertices and SCOTCH_graphMapFixed is used instead.
Scotch.graph_remap — Functiongraph_remap(
graph::Graph, arch::Arch, old_partition::Vector{SCOTCH_Num},
cost_factor::Float64, costs::Vector{SCOTCH_Num}, strat::Strat;
partition=nothing, fixed=false
)Compute a mapping from an old_partition, costs and cost_factor, using SCOTCH_graphRemap. Returns partition, with indices starting from 0.
If fixed == true, then partition (0-index) gives the fixed vertices and SCOTCH_graphRemapFixed is used instead.
Scotch.graph_part — Functiongraph_part(graph::Graph, parts, strat::Strat; partition=nothing, fixed=false, overlap=false)Partitions the graph into parts, with the given strategy, using SCOTCH_graphPart. Returns partition, with indices starting from 0.
If fixed == true, then partition (0-index) gives the fixed vertices and SCOTCH_graphPartFixed is used instead.
If overlap == true, then SCOTCH_graphPartOvl is used instead.
Scotch.graph_repart — Functiongraph_repart(
graph::Graph, parts, old_partition::Vector{SCOTCH_Num},
cost_factor::Float64, costs::Vector{SCOTCH_Num}, strat::Strat;
partition=nothing, fixed=false
)Re-partitions the graph into parts, with the old_partition, costs and cost_factor, using SCOTCH_graphRepart. Returns partition, with indices starting from 0.
If fixed == true, then partition (0-index) gives the fixed vertices and SCOTCH_graphRepartFixed is used instead.
Mesh
Scotch.Mesh — TypeMeshWrapper around a SCOTCH_Mesh pointer.
References to the arrays which may have been used to build the mesh are stored in the struct, preventing them from being GC'ed by Julia.
Scotch.mesh_alloc — Functionmesh_alloc()Allocate a new Mesh with SCOTCH_meshAlloc, then initialize it with SCOTCH_meshInit.
Finalizers will properly call SCOTCH_meshExit then SCOTCH_memFree once unused.
Scotch.mesh_build — Functionmesh_build(adj_index::Vector{SCOTCH_Num}, adj_array::Vector{SCOTCH_Num}, elem_count, node_count;
index_start_element=1, index_start_node=1, check=true, arc_count=length(adj_array),
adj_index_end::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
element_load ::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
vertex_load ::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
vertex_labels::Union{Vector{SCOTCH_Num}, Nothing}=nothing,
)Allocate and initialize a new Mesh using SCOTCH_meshBuild.
arc_count is twice the number of edges. The default value assumes that adj_array is compact.
If check == true, then SCOTCH_meshCheck may throw an error if the mesh is invalid.
Scotch.mesh_data — Functionmesh_data(mesh::Mesh)Returns a NamedTuple containing:
(;
base_element_index, base_node_index,
n_elements, n_nodes, n_arcs, n_edges,
adj_idx, adj_idx_end,
elements_weights, nodes_weights, vertex_labels,
adj_array,
max_vertex_degree
)Arrays are either nothing or wrapped into a Vector{SCOTCH_Num}. They share the data with the underlying mesh.
Scotch.mesh_load — Functionmesh_load(file::IO; index_start=nothing)
mesh_load(filename::AbstractString; kwargs...)Load a new Mesh from file with SCOTCH_meshLoad.
If index_start == nothing, then the base indexing of the file is conserved.
Scotch.mesh_graph — Functionmesh_graph(mesh::Mesh; dual=false, n_com=2)Create a new Graph from the mesh using SCOTCH_meshGraph.
If dual == true, then SCOTCH_meshGraphDual is used instead, with n_com being the minimum number of shared mesh elements for an edge to be created being two vertices.
Scotch.mesh_size — Functionmesh_size(mesh::Mesh)Returns the number of (; elements, nodes, edges) for the mesh, using SCOTCH_meshSize.
Scotch.mesh_stat — Functionmesh_stat(mesh::Mesh)Statistics about the mesh: returns (; node_load, element_degree, node_degree). Each value contains the following fields: min, max, sum (only for node_load), avg (average) and var (standard deviation).
Block ordering
Scotch.block_ordering — Functionblock_ordering(graph_or_mesh::Union{Graph, Mesh}, strat::Strat;
permutation ::Union{Bool, Nothing, Vector{SCOTCH_Num}}=nothing,
inv_permutation::Union{Bool, Nothing, Vector{SCOTCH_Num}}=nothing,
columns ::Union{Bool, Nothing, Vector{SCOTCH_Num}}=nothing,
separators_tree::Union{Bool, Nothing, Vector{SCOTCH_Num}}=nothing
)Compute a block ordering of the graph or mesh using SCOTCH_graphOrder or SCOTCH_meshOrder. Returns (permutation, inv_permutation, num_blocks, columns, separators_tree).
permutation, inv_permutation, columns or separators_tree can have 3 values each:
nothing: converted toC_NULLand subsequantly ignoredtrue: a new vector of the appropriate size is allocated and returned- a
Vector{SCOTCH_Num}: used and returned without allocation
Context
Scotch.Context — TypeContextWrapper around a SCOTCH_Context pointer.
Scotch.context_alloc — Functioncontext_alloc()Allocate a new Context with SCOTCH_contextAlloc, then initialize it with SCOTCH_contextInit.
Finalizers will properly call SCOTCH_contextExit then SCOTCH_memFree once unused.
Scotch.random_clone — Functionrandom_clone(ctx::Context)Clone the global RNG state into ctx using SCOTCH_contextRandomClone.
Scotch.random_seed — Methodrandom_seed(ctx::Context, seed)Set the RNG seed of ctx using SCOTCH_contextRandomSeed.
Scotch.random_reset — Methodrandom_reset(ctx::Context)Resets the RNG of ctx using SCOTCH_contextRandomReset.
Scotch.context_option — Functioncontext_option(ctx::Context, option::Symbol)Get the option for ctx to value using SCOTCH_contextOptionGetNum.
option can be:
:deterministicforSCOTCH_OPTIONNUMDETERMINISTIC:fixed_seedforSCOTCH_OPTIONNUMRANDOMFIXEDSEED
Scotch.context_option! — Functioncontext_option!(ctx::Context, option::Symbol, value::Bool)Set the option for ctx to value using SCOTCH_contextOptionSetNum.
option can be:
:deterministicforSCOTCH_OPTIONNUMDETERMINISTIC:fixed_seedforSCOTCH_OPTIONNUMRANDOMFIXEDSEED
Scotch.bind_graph — Functionbind_graph(ctx::Context, graph::Graph)Create a new Graph from graph bound to ctx using SCOTCH_contextBindGraph.
Scotch.bind_mesh — Functionbind_graph(ctx::Context, mesh::Mesh)Create a new Graph from mesh bound to ctx using SCOTCH_contextBindGraph.
Utilities
Scotch.save — Functionsave(obj, filename::AbstractString)Saves obj to the given filename.
save(strat::Strat, file::IO)Save the strat to file.
save(arch::Arch, file::IO)Save the arch to file using SCOTCH_archSave.
save(graph::Graph, file::IO)Save the graph to file using SCOTCH_graphSave.
save(mesh::Mesh, file::IO)Save the mesh to file using SCOTCH_meshSave.
Scotch.random_seed — Methodrandom_seed(seed)Sets the global RNG seed using SCOTCH_randomSeed.
Scotch.random_reset — Methodrandom_reset()Resets the global RNG seed using SCOTCH_randomReset.
Scotch.version — Functionversion()The version of the loaded SCOTCH library. Calls SCOTCH_version.
Types
Scotch.LibScotch.SCOTCH_Num — TypeSCOTCH_NumInteger type (should be a Cint/Int32 on most machines).
Scotch.LibScotch.SCOTCH_GraphPart2 — TypeSCOTCH_GraphPart2Small integer type (should be a Cuchar/UInt8 on most machines).