Answer the question
In order to leave comments, you need to log in
What is the analogy in PHP?
In C++:
list *adj = new list[V];
adj[v].push_back(w);
What can be composed from an array similar or something else?
I tried using SplDoublyLinkedList but it won't work like this adj[v].push_back(w)
How can I save data in the same form in php?
UPD:
I'll try to put the question differently, because the problem is most likely not in this.
Here is the C++ code , I need to rewrite it in php. Here is what I wrote PHP code
But it doesn't work. Writes that the recursion has crossed a possible threshold.
Answer the question
In order to leave comments, you need to log in
65 (cpp) a = b = ++time;
37 (php) a = b; // a = b = ++Graph::$time; ?
At a cursory glance, you are sending to the infinite recursion in line 49 (php). $u (aka $v), then 1, then 0, then 1, then 0...
I could be wrong, but it seems the problem is in line 37 of the php code.
you either delete the PHP tag, and wait for answers only from sipipishnikov, or explain clearly what you need.
As far as I understood, you need to add elements to the end of the array. It is done like this:
$myArray = []; // объявляем массив
$myArray[] = 'custom value'; // добавит элемент в конец массива
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question