# Tag Info

4

For this question, I can find some code of python version, Refs. here. And I rewrote this Ising simulation as Mathematica version, as follow, 1. Define a function used for generating a table (as configuration) Initialstate[n_Integer] := 2*Table[RandomInteger[], {n}, {n}] - 1 where n as the number of points. And define a function used for getting any point'...

4

func = 3; func[2, 3] = 5; func[3, 4, 5] = 9; To get a list of all the inputs and outputs of a function you can use DownValues. DownValues@func {HoldPattern[func] :> 3, HoldPattern[func[2, 3]] :> 5, HoldPattern[func[3, 4, 5]] :> 9} Then to get all the inputs associated with explicit definitions, first replace the func head with List (in case of ...

2

One potential bottleneck is incidv = Flatten[Position[edges, (v \[UndirectedEdge] _ | _ \[UndirectedEdge] v)]] as it involves (i) a search in the rather long list of edges and (ii) pattern matching, which both tend to be rather slow. A quicker way will be to compute all these lists at once via vertexedgeincidences = IncidenceMatrix[G]["AdjacencyLists"]; ...

0

Here is a Code that @kglr developed as an answer to my Linear Programming problem. The flow between any source s and any target t can be found for directed graphs with vertices having two types of capacities: Absorption and Distribution capacities. One can find out all the existing pathways between a source s and a target t, as well as the associated maximum ...

7

It seems like you forgot to remember current orientation of the ant: ClearAll["Global`*"] mat = ConstantArray[0, {100, 100}]; pos = {50, 50, -90 °}; s = Table[ seq = Sequence @@ Most@pos; Which[ mat[[seq]] == 0, {pos = Flatten@Last@AnglePath[Most@pos, {Last@pos + 90 °}, {"Position", "FrameAngle"}], mat[[seq]] = 1} , mat[[seq]] == 1, {pos = ...

Top 50 recent answers are included