Skip to main content
added 340 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Construct an edge list from given information and use FindIndependentEdgeSet:

fruits = {pear, apple, plum, grape, banana};

colors = {{Red, Green, Yellow}, {Red, Green}, {Purple}, {Red, Green, 
    Purple}, {Blue, Yellow}};

edges = Flatten @ MapThread[Thread @* UndirectedEdge, {fruits, colors}];

FindIndependentEdgeSet @ edges

enter image description here

Graph[edges, GraphLayout -> "BipartiteEmbedding",  VertexLabels -> Automatic]

enter image description here

To get all matchings, we can use this method by Szabolcs:

lg = LineGraph[edges];

edges[[#]] & /@ FindIndependentVertexSet[lg, 
     Length /@ FindIndependentVertexSet[lg], All]

enter image description here

Construct an edge list from given information and use FindIndependentEdgeSet:

fruits = {pear, apple, plum, grape, banana};

colors = {{Red, Green, Yellow}, {Red, Green}, {Purple}, {Red, Green, 
    Purple}, {Blue, Yellow}};

edges = Flatten @ MapThread[Thread @* UndirectedEdge, {fruits, colors}];

FindIndependentEdgeSet @ edges

enter image description here

Graph[edges, GraphLayout -> "BipartiteEmbedding",  VertexLabels -> Automatic]

enter image description here

Construct an edge list from given information and use FindIndependentEdgeSet:

fruits = {pear, apple, plum, grape, banana};

colors = {{Red, Green, Yellow}, {Red, Green}, {Purple}, {Red, Green, 
    Purple}, {Blue, Yellow}};

edges = Flatten @ MapThread[Thread @* UndirectedEdge, {fruits, colors}];

FindIndependentEdgeSet @ edges

enter image description here

Graph[edges, GraphLayout -> "BipartiteEmbedding",  VertexLabels -> Automatic]

enter image description here

To get all matchings, we can use this method by Szabolcs:

lg = LineGraph[edges];

edges[[#]] & /@ FindIndependentVertexSet[lg, 
     Length /@ FindIndependentVertexSet[lg], All]

enter image description here

Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Construct an edge list from given information and use FindIndependentEdgeSet:

fruits = {pear, apple, plum, grape, banana};

colors = {{Red, Green, Yellow}, {Red, Green}, {Purple}, {Red, Green, 
    Purple}, {Blue, Yellow}};

edges = Flatten @ MapThread[Thread @* UndirectedEdge, {fruits, colors}];

FindIndependentEdgeSet @ edges

enter image description here

Graph[edges, GraphLayout -> "BipartiteEmbedding",  VertexLabels -> Automatic]

enter image description here