|
77 | 77 |
|
78 | 78 | hypergraphPlot[args___] /; !Developer`CheckArgumentCount[HypergraphPlot[args], 1, 2] := $Failed;
|
79 | 79 |
|
80 |
| -(* allow composite vertices, but not list-vertices *) |
81 |
| -$hypergraphPattern = _List ? (Function[h, AllTrue[h, ListQ[#] && Length[#] > 0 &] && AllTrue[h, Not @* ListQ, 2]]); |
82 |
| -$multiHypergraphPattern = $hypergraphPattern | {$hypergraphPattern...}; |
| 80 | +$hypergraphPattern = _List ? (Function[h, VectorQ[h, (ListQ[#] && (# =!= {})) &]]); |
83 | 81 |
|
84 | 82 | declareMessage[
|
85 | 83 | General::invalidEdges,
|
86 |
| - "First argument of HypergraphPlot must be a hypergraph, i.e., a list of lists, " <> |
87 |
| - "where elements represent vertices, or a list of such hypergraphs."]; |
| 84 | + "First argument of HypergraphPlot must be a hypergraph, i.e., a list of lists, where elements represent vertices."]; |
88 | 85 |
|
89 |
| -hypergraphPlot[Except[$multiHypergraphPattern], _ : $defaultEdgeType, OptionsPattern[]] := |
| 86 | +hypergraphPlot[Except[$hypergraphPattern], _ : $defaultEdgeType, OptionsPattern[]] := |
90 | 87 | throw[Failure["invalidEdges", <||>]];
|
91 | 88 |
|
92 | 89 | declareMessage[General::invalidEdgeType, "Edge type `type` should be one of `allowedTypes`."];
|
93 | 90 |
|
94 |
| -hypergraphPlot[$multiHypergraphPattern, |
95 |
| - edgeType : Except[Alternatives[Alternatives @@ $edgeTypes, OptionsPattern[]]], |
96 |
| - OptionsPattern[]] := |
| 91 | +hypergraphPlot[$hypergraphPattern, |
| 92 | + edgeType : Except[Alternatives[Alternatives @@ $edgeTypes, OptionsPattern[]]], |
| 93 | + OptionsPattern[]] := |
97 | 94 | throw[Failure["invalidEdgeType", <|"type" -> edgeType, "allowedTypes" -> $edgeTypes|>]];
|
98 | 95 |
|
99 |
| -hypergraphPlot[ |
100 |
| - edges : {$hypergraphPattern..}, edgeType : Alternatives @@ $edgeTypes : $defaultEdgeType, o : OptionsPattern[]] := ( |
101 |
| - checkHypergraphPlotOptions[HypergraphPlot, edges, {o}]; |
102 |
| - hypergraphPlot[#, edgeType, o] & /@ edges |
103 |
| -); |
104 |
| - |
105 | 96 | parseHighlight[_, _, {}, _] := ConstantArray[Automatic, 3];
|
106 | 97 |
|
107 | 98 | parseHighlight[vertices_, edges_, highlightList_, highlightStyle_] := ModuleScope[
|
|
210 | 201 | checkSize["Vertex size", OptionValue[HypergraphPlot, options, VertexSize], {}];
|
211 | 202 | checkSize["Arrowhead length", OptionValue[HypergraphPlot, options, "ArrowheadLength"], {Automatic}];
|
212 | 203 | checkPlotStyle[OptionValue[HypergraphPlot, options, PlotStyle]];
|
213 |
| - checkStyleLength["vertices", |
214 |
| - MatchQ[edges, {$hypergraphPattern..}], |
215 |
| - Length[vertexList[edges]], |
216 |
| - OptionValue[HypergraphPlot, options, VertexStyle]]; |
217 |
| - checkStyleLength[ |
218 |
| - "edges", MatchQ[edges, {$hypergraphPattern..}], Length[edges], OptionValue[HypergraphPlot, options, #]] & /@ |
| 204 | + checkStyleLength["vertices", Length[vertexList[edges]], OptionValue[HypergraphPlot, options, VertexStyle]]; |
| 205 | + checkStyleLength["edges", Length[edges], OptionValue[HypergraphPlot, options, #]] & /@ |
219 | 206 | {EdgeStyle, "EdgePolygonStyle"};
|
220 | 207 | );
|
221 | 208 |
|
|
247 | 234 |
|
248 | 235 | checkPlotStyle[style_List] := throw[Failure["invalidPlotStyle", <|"plotStyle" -> style|>]];
|
249 | 236 |
|
250 |
| -(* Single hypergraph *) |
251 | 237 | declareMessage[General::invalidStyleLength,
|
252 | 238 | "The list of styles `styles` should have the same length `correctLength` as the number of `name`."];
|
253 | 239 |
|
254 |
| -checkStyleLength[name_, False, correctLength_, styles_List] /; Length[styles] =!= correctLength := |
| 240 | +checkStyleLength[name_, correctLength_, styles_List] /; Length[styles] =!= correctLength := |
255 | 241 | throw[Failure["invalidStyleLength", <|"styles" -> styles, "name" -> name, "correctLength" -> correctLength|>]];
|
256 | 242 |
|
257 |
| -(* Multiple hypergraphs *) |
258 |
| -declareMessage[General::multigraphElementwiseStyle, |
259 |
| - "The elementwise style specification `styleSpec` is not supported for lists of hypergraphs."]; |
260 |
| - |
261 |
| -checkStyleLength[_, True, _, styles_List] := throw[Failure["multigraphElementwiseStyle", <|"styleSpec" -> styles|>]]; |
262 |
| - |
263 | 243 | (* Implementation *)
|
264 | 244 |
|
265 | 245 | hypergraphPlotImplementation[
|
|
0 commit comments