Module: RbMetis

Defined in:
lib/rbmetis/lib.rb,
lib/rbmetis/main.rb,
lib/rbmetis/version.rb

Defined Under Namespace

Classes: MetisError

Constant Summary collapse

METIS_OK =

Returned normally

1
METIS_ERROR_INPUT =

Returned due to erroneous inputs and/or options

-2
#  Returned due to insufficient memory
METIS_ERROR_MEMORY =

Returned due to insufficient memory

-3
#  Some other errors
METIS_ERROR =

Some other errors

-4
NOPTIONS =
40
DBG_INFO =

/*! Debug Levels */

1
DBG_TIME =
2
DBG_COARSEN =
4
DBG_REFINE =
8
DBG_IPART =
16
DBG_MOVEINFO =
32
DBG_SEPINFO =
64
DBG_CONNINFO =
128
DBG_CONTIGINFO =
256
DBG_MEMORY =
2048
VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.default_optionsArray

Initializes the options array into its default values. It’s size is METIS_NOPTIONS.

Returns:

  • (Array)

    The array of options that will be initialized.



253
254
255
256
257
# File 'lib/rbmetis/main.rb', line 253

def default_options
  options = Lib.alloc_idx_ary([0]*40)
  Lib.METIS_SetDefaultOptions(options)
  Lib.read_idx_ary(options,40)
end

.part_graph_kway(xadj, adjncy, npart, opts = {}) ⇒ Array

partition a graph into k parts using multilevel k-way partitioning.

Parameters:

  • xadj (Array)

    adjacency structure of the graph

  • adjncy (Array)

    adjacency structure of the graph

  • npart (Integer)

    the number of partitions

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :vwgt (Array) — default: nil

    The weights of the vertices.

  • :ncon (Array) — default: 1

    The number of balancing constraints. It should be at least 1.

  • :vsize (Array) — default: nil

    The size of the vertices for computing the total communication volume.

  • :adjwgt (Array) — default: nil

    The weights of the edges.

  • :tpwgts (Array) — default: nil

    an array of size nparts*ncon that specifies the desired weight for each partition and constraint. The target partition weight for the ith partition and jth constraint is specified at tpwgts For each constraint, the sum of the tpwgts[] entries must be 1.0.

  • :ubvec (Array) — default: nil

    an array of size ncon that specifies the allowed load imbalance tolerance for each constraint. For the ith partition and jth constraint the allowed weight is the ubvec*tpwgts fraction of the jth’s constraint total weight. The load imbalances must be greater than 1.0. A NULL value can be passed indicating that the load imbalance tolerance for each constraint should be 1.001 (for ncon=1) or 1.01 (for ncon>1).

  • :options (Array) — default: nil

    the array of options. The following options are valid for METIS PartGraphKway: METIS_OPTION_OBJTYPE, METIS_OPTION_CTYPE, METIS_OPTION_IPTYPE, METIS_OPTION_RTYPE, METIS_OPTION_NO2HOP, METIS_OPTION_NCUTS, METIS_OPTION_NITER, METIS_OPTION_UFACTOR, METIS_OPTION_MINCONN, METIS_OPTION_CONTIG, METIS_OPTION_SEED, METIS_OPTION_NUMBERING, METIS_OPTION_DBGLVL

Returns:

  • (Array)

    an array that stores the partition of the graph.

Raises:



237
238
239
240
241
242
243
244
245
246
247
# File 'lib/rbmetis/main.rb', line 237

def part_graph_kway(xadj, adjncy, npart, opts={})
  # args = [ nvtxs, ncon, xadj, adjncy, vwgt, vsize, adjwgt, nparts,
  #          tpwgts, ubvec, options, objval, part ]
  args = Lib.part_graph_preprocess(xadj, adjncy, npart, opts)
  retval = Lib.METIS_PartGraphKway(*args)
  Lib.postprocess(retval)
  part = args.last
  nv = xadj.size - 1
  #p read_idx(objval)
  return Lib.read_idx_ary(part,nv)
end

.part_graph_recursive(xadj, adjncy, npart, opts = {}) ⇒ Array

partition a graph into k parts using multilevel recursive bisection.

Parameters:

  • xadj (Array)

    adjacency structure of the graph

  • adjncy (Array)

    adjacency structure of the graph

  • npart (Integer)

    the number of partitions

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :vwgt (Array) — default: nil

    The weights of the vertices.

  • :ncon (Array) — default: 1

    The number of balancing constraints. It should be at least 1.

  • :vsize (Array) — default: nil

    The size of the vertices for computing the total communication volume.

  • :adjwgt (Array) — default: nil

    The weights of the edges.

  • :tpwgts (Array) — default: nil

    an array of size nparts*ncon that specifies the desired weight for each partition and constraint. The target partition weight for the ith partition and jth constraint is specified at tpwgts For each constraint, the sum of the tpwgts[] entries must be 1.0.

  • :ubvec (Array) — default: nil

    an array of size ncon that specifies the allowed load imbalance tolerance for each constraint. For the ith partition and jth constraint the allowed weight is the ubvec*tpwgts fraction of the jth’s constraint total weight. The load imbalances must be greater than 1.0. A NULL value can be passed indicating that the load imbalance tolerance for each constraint should be 1.001 (for ncon=1) or 1.01 (for ncon>1).

  • :options (Array) — default: nil

    the array of options. The following options are valid for METIS PartGraphRecursive: METIS_OPTION_CTYPE, METIS_OPTION_IPTYPE, METIS_OPTION_RTYPE, METIS_OPTION_NO2HOP, METIS_OPTION_NCUTS, METIS_OPTION_NITER, METIS_OPTION_SEED, METIS_OPTION_UFACTOR, METIS_OPTION_NUMBERING, METIS_OPTION_DBGLVL

Returns:

  • (Array)

    an array that stores the partition of the graph.

Raises:



190
191
192
193
194
195
196
197
198
199
200
# File 'lib/rbmetis/main.rb', line 190

def part_graph_recursive(xadj, adjncy, npart, opts={})
  # args = [ nvtxs, ncon, xadj, adjncy, vwgt, vsize, adjwgt, nparts,
  #          tpwgts, ubvec, options, objval, part ]
  args = Lib.part_graph_preprocess(xadj, adjncy, npart, opts)
  retval = Lib.METIS_PartGraphRecursive(*args)
  Lib.postprocess(retval)
  part = args.last
  nv = xadj.size - 1
  #p read_idx(objval)
  return Lib.read_idx_ary(part,nv)
end