bfutils#

all_undersamples#

gunfolds.utils.bfutils.all_undersamples(G_star)[source]#

Returns a list of all undersampled graphs (excluding superclique)

Parameters:

G_star (dictionary (gunfolds graphs)) – gunfolds format graph

Returns:

list of all undersampled graphs (excluding superclique)

Return type:

list of graphs

bidirected_inc#

gunfolds.utils.bfutils.bidirected_inc(G, D)[source]#

A helper function for determining bidirected edges in an undersampled graph given a previously undersampled graph

Parameters:
  • G (dictionary (gunfolds graphs)) – gunfolds format graph G_1 - without undersampling

  • D (dictionary (gunfolds graphs)) – gunfolds graph G_u a version of G_1 undersampled by u

Returns:

Return type:

call_u_conflicts#

gunfolds.utils.bfutils.call_u_conflicts(G_star, H)[source]#
Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • H

Returns:

Return type:

boolean

call_u_conflicts2#

gunfolds.utils.bfutils.call_u_conflicts2(G_star, H)[source]#
Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • H

Returns:

Return type:

call_u_conflicts_d#

gunfolds.utils.bfutils.call_u_conflicts_d(G_star, H)[source]#
Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • H

Returns:

Return type:

boolean

call_u_equals#

gunfolds.utils.bfutils.call_u_equals(G_star, H)[source]#
Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • H

Returns:

Return type:

boolean

call_u_equals2#

gunfolds.utils.bfutils.call_u_equals2(G_star, glist, H)[source]#
Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • glist (list of dictionaries (gunfolds graphs)) – a list of graphs that are undersampled versions of the same system

  • H

Returns:

Return type:

boolean

call_undersamples#

gunfolds.utils.bfutils.call_undersamples(G_star)[source]#

Returns a list of all undersampled graphs (including superclique)

Parameters:

G_star (dictionary (gunfolds graphs)) – gunfolds format graph

Returns:

list of all undersampled graphs (including superclique)

Return type:

list of graphs

cc_all#

gunfolds.utils.bfutils.cc_all(i, nodes, steps)[source]#
Parameters:
  • i

  • nodes

  • steps

Returns:

Return type:

cc_undersamples#

gunfolds.utils.bfutils.cc_undersamples(G_star, steps=1)[source]#

Returns G_u for G_star with default value of u=2. If the input graph converges before the requested u - an empty list is returned.

Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • steps (integer) – undersampling rate - 1 for G_star

Returns:

Return type:

check_conflict#

gunfolds.utils.bfutils.check_conflict(H, G_test, au=None)[source]#
Parameters:
  • H

  • G_test

  • au

Returns:

Return type:

check_conflict_#

gunfolds.utils.bfutils.check_conflict_(Hnum, G_test, au=None)[source]#
Parameters:
  • Hnum

  • G_test

  • au

Returns:

Return type:

check_equality#

gunfolds.utils.bfutils.check_equality(H, G_test, au=None)[source]#
Parameters:
  • H

  • G_test

  • au

Returns:

Return type:

compact_call_undersamples#

gunfolds.utils.bfutils.compact_call_undersamples(G_star)[source]#

Returns a list of all undersampled graphs (including superclique) in binary encoded format

Parameters:

G_star (dictionary (gunfolds graphs)) – gunfolds format graph

Returns:

a list of all undersampled graphs (including superclique) in binary encoded format

Return type:

list of integers

compat#

gunfolds.utils.bfutils.compat(G)[source]#
Parameters:

G (dictionary (gunfolds graphs)) – gunfolds format graph

Returns:

Return type:

compatible#

gunfolds.utils.bfutils.compatible(d1, d2)[source]#
Parameters:
  • d1

  • d2

Returns:

Return type:

dens2edgenum#

gunfolds.utils.bfutils.dens2edgenum(d, n=10)[source]#

Convert density into the number of extra edges needed for a ring graph to achieve that density

Parameters:
  • d (float) – density

  • n (integer) – number of nodes in the graph

Returns:

number of extra edges needed for a ring graph to achieve that density

Return type:

integer

dincrement_u#

gunfolds.utils.bfutils.dincrement_u(G_star, G_u)[source]#
Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • G_u

Returns:

Return type:

directed_inc#

gunfolds.utils.bfutils.directed_inc(G, D)[source]#

A helper function for determining directed edges in an undersampled graph given a previously undersampled graph

Parameters:
  • G (dictionary (gunfolds graphs)) – gunfolds format graph G_1 - without undersampling

  • D (dictionary (gunfolds graphs)) – gunfolds graph G_u a version of G_1 undersampled by u

Returns:

Return type:

dictionary (gunfolds graphs)

edgenum2dens#

gunfolds.utils.bfutils.edgenum2dens(e, n=10)[source]#

Convert number of edges excluding edges of the ring to density

Parameters:
  • e (integer) – number of edges excluding edges of the ring

  • n (integer) – number of nodes in the graph

Returns:

density

Return type:

double

forms_loop#

gunfolds.utils.bfutils.forms_loop(G_star, loop)[source]#
Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph

  • loop

Returns:

Return type:

boolean

iall#

gunfolds.utils.bfutils.iall(i, nodes)[source]#
Parameters:
  • i

  • nodes

Returns:

Return type:

icompat#

gunfolds.utils.bfutils.icompat(i, nodes)[source]#
Parameters:
  • i

  • nodes

Returns:

Return type:

ilength#

gunfolds.utils.bfutils.ilength(i, nodes)[source]#
Parameters:
  • i

  • nodes

Returns:

Return type:

increment#

gunfolds.utils.bfutils.increment(G)[source]#

Undersample G by 2 only works for G1 to G2 directed

Parameters:

G (dictionary (gunfolds graphs)) – gunfolds format graph

Returns:

undersampled graph

Return type:

dictionary (gunfolds graphs)

increment_u#

gunfolds.utils.bfutils.increment_u(G_star, G_u)[source]#

Given graph G_star - without undersampling - and its undersampled version G_u, generate the G_{u+1} graph

Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph G_1 - without undersampling

  • G_u (dictionary (gunfolds graphs)) – gunfolds graph G_u a version of G_1 undersampled by u

Returns:

Return type:

is_sclique#

gunfolds.utils.bfutils.is_sclique(G)[source]#

Tests if the graph is a superclique (all possible connections)

Parameters:

G (dictionary (gunfolds graphs)) – gunfolds format graph

Returns:

True, if G is a super clique

Return type:

boolean

loadgraphs#

gunfolds.utils.bfutils.loadgraphs(fname)[source]#

Loads a graph from a zickle file

Parameters:

fname (string) – file name

Returns:

gunfolds graph

Return type:

dictionary (gunfolds graphs)

make_rect#

gunfolds.utils.bfutils.make_rect(l)[source]#
Parameters:

l

Returns:

Return type:

overshoot#

gunfolds.utils.bfutils.overshoot(G_star, H)[source]#

Undersample G_star until it turns into a G_u for which H is an edge subset. Return True in this case. If this does not happen for either of the undersampling rates until teh convergence - return False

Parameters:
  • G_star (dictionary (gunfolds graphs)) – gunfolds format graph at u=1

  • H (dictionary (gunfolds graphs)) – gunfolds format graph at some u

Returns:

Return type:

boolean

pure_directed_inc#

gunfolds.utils.bfutils.pure_directed_inc(G, D)[source]#
Parameters:
  • G (dictionary (gunfolds graphs)) – gunfolds format graph G_1 - without undersampling

  • D (dictionary (gunfolds graphs)) – gunfolds graph G_u a version of G_1 undersampled by u

Returns:

Return type:

savegraphs#

gunfolds.utils.bfutils.savegraphs(l, fname)[source]#

Saves a graph into a zickle file format

Parameters:
  • l (dictionary (gunfolds graphs)) – gunfolds graph

  • fname (string) – file name

undersample#

gunfolds.utils.bfutils.undersample(G, u)[source]#

Undersample graph G by rate u

Parameters:
  • G (dictionary (gunfolds graphs)) – gunfolds format graph

  • u (integer) – undersampling rate

Returns:

undersampled graph

Return type:

dictionary (gunfolds graphs)