Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions scpc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1210,9 +1210,9 @@
" new_labeling = facets_relabeling(facets_list, perm)\n",
" ## Check if this labeling makes the CS weakly-chordal\n",
" if is_w_chordal_labeling(new_labeling):\n",
" print('The labeling', new_labeling, 'makes this CS weakly-chordal')\n",
" #print('The labeling', new_labeling, 'makes this CS weakly-chordal')\n",
" return new_labeling\n",
" print('Not weakly-chordal.')\n",
" #print('Not weakly-chordal.')\n",
" return []\n",
"\n",
"##############################################################################\n",
Expand Down Expand Up @@ -1244,7 +1244,7 @@
"from itertools import combinations\n",
"\n",
"## Note: not checking for the same max of F and G\n",
"def w_chordal_for_pair_of_facets (F, G, facets_labeling):\n",
"def w_chordal_for_pair_of_facets_s (F, G, facets_labeling):\n",
" ## Do union of elements of F and G without repetitions\n",
" union_F_G = list(set(F + G))\n",
" ## Remove the largest label\n",
Expand All @@ -1263,12 +1263,12 @@
"##############################################################################\n",
"## Fucntion to check if a given labeling is weakly-chordal\n",
"## Find all facet pairs with the same maximum and check weak-chordality condition for them\n",
"def is_w_chordal_labeling (facets_labeling):\n",
"def is_w_chordal_labeling_s (facets_labeling):\n",
" ## Going through all the facet pairs (F, G)\n",
" for var in combinations(facets_labeling, 2):\n",
" ## If the maximum of F and G is the same, check the w-chord condition\n",
" if var[0][-1] == var[1][-1]:\n",
" if not w_chordal_for_pair_of_facets(var[0], var[1], facets_labeling):\n",
" if not w_chordal_for_pair_of_facets_s(var[0], var[1], facets_labeling):\n",
" # print('This labeling is not w-chordal. The trouble pair is', var[0], var[1] )\n",
" return False\n",
" # print('ok pair')\n",
Expand All @@ -1282,16 +1282,18 @@
"## Check the weakly-chordal condition for every skeleton for a given labeling\n",
"\n",
"def is_ws_chordal_labeling (facets_list):\n",
" if not is_w_chordal_labeling(facets_list):\n",
" if not is_w_chordal_labeling_s(facets_list):\n",
" return False\n",
" d_plus_one = len(facets_list[0])\n",
" for k in range(2,d_plus_one):\n",
" k_skeleton_repetitions = []\n",
" for F in facets_list:\n",
" k_faces = [*combinations(F,k)]\n",
" k_skeleton_repetitions.extend(k_faces)\n",
" k_skeleton = sorted(list(set(k_skeleton_repetitions)))\n",
" if not is_w_chordal_labeling(k_skeleton):\n",
" k_skeleton_tuples = sorted(list(set(k_skeleton_repetitions)))\n",
" k_skeleton = [list(elem) for elem in k_skeleton_tuples]\n",
" # print('skeleton', k_skeleton)\n",
" if not is_w_chordal_labeling_s(k_skeleton):\n",
" return False\n",
" return True\n",
"\n",
Expand All @@ -1307,9 +1309,9 @@
" new_labeling = facets_relabeling(facets_list, perm)\n",
" ## Check if this labeling makes the CS weakly-chordal\n",
" if is_ws_chordal_labeling(new_labeling):\n",
" print('The labeling', new_labeling, 'makes this CS ws-chordal')\n",
" #print('The labeling', new_labeling, 'makes this CS s-chordal')\n",
" return new_labeling\n",
" print('Not ws-chordal.')\n",
" #print('Not s-chordal.')\n",
" return []\n",
"\n",
"########################################################################\n",
Expand Down