Hypergraph Geodesics
Hypergraph Geodesics
Max Piskunov : 18d5b5be502016a808b7fc60889568d42ce95b95
Source Code
Source Code
User Policies
User Policies
In[]:=
excludeUser[username_]:=Function[expr,If[$UserName=!=username,expr],HoldAll]
In[]:=
excludeStephen=excludeUser["sw"];
Dependencies
Dependencies
In[]:=
excludeStephen[<<SetReplace`;Quiet[ParallelEvaluate[<<SetReplace`],CloudConnect::clver]];
Geodesics Plotting
Geodesics Plotting
In[]:=
findShortestPath[edges_,endpoints:{{_,_}...}]:=FindShortestPath[Catenate[Partition[#,2,1,1]&/@edges],#,#2]&@@@endpoints
In[]:=
pathEdges[edges_,path_]:=Select[Count[Alternatives@@path]@#≥2&]@edges
In[]:=
plotGeodesic[edges_,endpoints:{{_,_}...},o:OptionsPattern[]]:=With[{vertexPaths=findShortestPath[edges,endpoints]},WolframModelPlot[edges,o,GraphHighlightCatenate[pathEdges[edges,#]~Join~#&/@vertexPaths]]]
In[]:=
plotGeodesic[edges_,endpoints:{__:Except@List},o:OptionsPattern[]]:=plotGeodesic[edges,{endpoints},o]
In[]:=
plotRandomGeodesic[edges_,o:OptionsPattern[]]:=With[{vertices=Union@Catenate@edges},plotGeodesic[edges,Table[RandomChoice@vertices,2],o]]
Examples
Examples
In[]:=
plotGeodesic[WolframModel[{{1,2,3},{4,2,5}}{{6,3,1},{3,6,4},{1,2,6}},Automatic,1000]@"FinalState",{{924,1000},{738,951},{874,948}},VertexSize0.12]
Out[]=
In[]:=
plotRandomGeodesic[WolframModel[{{1,2,3},{4,2,5}}{{6,3,1},{3,6,4},{1,2,6}},Automatic,1000]@"FinalState",VertexSize0.12]
Out[]=