Skip to main content
added 73 characters in body
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47

If we extend this code further, we could build an AdjacencyMatrix in which we want to select a minimum set of nodes that are never incident towe can reach all the same edge vertices with at most 1 step(like FindIndependentVertexSet but in minimum terms and little refinement, vertices can be two sides of an edge):

If we extend this code further, we could build an AdjacencyMatrix in which we want to select a minimum set of nodes that are never incident to the same edge (like FindIndependentVertexSet but in minimum terms):

If we extend this code further, we could build an AdjacencyMatrix in which we want to select a minimum set of nodes that we can reach all the vertices with at most 1 step(like FindIndependentVertexSet but in minimum terms and little refinement, vertices can be two sides of an edge):

added 14 characters in body
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47
graphRules = 
  DeleteDuplicatesBy[Sort]@
   Catenate@
    Table[Thread[
      index \[UndirectedEdge] 
       Catenate@
        Position[pairs, 
         Alternatives @@ 
          Table[ReplacePart[pairs[[index]], i -> _], {i, 
            3}], {1}]], {index, Length@pairsn}];

adjacency = Unitize@AdjacencyMatrix[graphRules];
Software/Language Time (second)
Mathematica 13.0.1 (LinearOptimization) 21
Matlab 2021a (intlinprog) 11
Julia 1.7.2 (HiGHS 1.1.3 - 2nd time) 1.5
graphRules = 
  DeleteDuplicatesBy[Sort]@
   Catenate@
    Table[Thread[
      index \[UndirectedEdge] 
       Catenate@
        Position[pairs, 
         Alternatives @@ 
          Table[ReplacePart[pairs[[index]], i -> _], {i, 
            3}], {1}]], {index, Length@pairs}];

adjacency = Unitize@AdjacencyMatrix[graphRules];
Software/Language Time (second)
Mathematica (LinearOptimization) 21
Matlab (intlinprog) 11
Julia (HiGHS - 2nd time) 1.5
graphRules = 
  DeleteDuplicatesBy[Sort]@
   Catenate@
    Table[Thread[
      index \[UndirectedEdge] 
       Catenate@
        Position[pairs, 
         Alternatives @@ 
          Table[ReplacePart[pairs[[index]], i -> _], {i, 
            3}], {1}]], {index, n}];

adjacency = Unitize@AdjacencyMatrix[graphRules];
Software/Language Time (second)
Mathematica 13.0.1 (LinearOptimization) 21
Matlab 2021a (intlinprog) 11
Julia 1.7.2 (HiGHS 1.1.3 - 2nd time) 1.5
added 238 characters in body
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47

Update 2

For checking the correctness you can use:

DeleteCases[pairs, 
 Alternatives @@ (({#1, #2, _} | {#1, _, #3} | {_, #2, #3}) & @@@ chosen)]

Where pairs are all the points and chosen are the picked ones.

Update 2

For checking the correctness you can use:

DeleteCases[pairs, 
 Alternatives @@ (({#1, #2, _} | {#1, _, #3} | {_, #2, #3}) & @@@ chosen)]

Where pairs are all the points and chosen are the picked ones.

added 60 characters in body
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47
Loading
added 1746 characters in body
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47
Loading
Add a picture
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47
Loading
added 9 characters in body
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47
Loading
added 9 characters in body
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47
Loading
Source Link
Ben Izd
  • 9.5k
  • 1
  • 15
  • 47
Loading