Should i work with tree representation as an array of nodes and an array of edges Here is the problem, i have a graphical component that displays a tree. It takes as input an array of nodes and array of edges(eg:an edge has a source and target).
I will be performing complex tasks, such as building the tree dynamically from user input, removing nodes adding nodes, hiding a node's children, i would need to traverse certain paths and collect information, and all things of tree such as getting children of a node or get all leafs etc.
I have two solutions: either manipulate directly both arrays i already tried with hiding a node's children and it was fine.
Or map the two array into a tree structure and manipulate the tree to do what i want since there will lots of ready algorithms then map it back to the two arrays.
The first solution sounds better and easier at first, however if  things get more complex i will implement each function i need (such getting leafs etc) and the diffculty is manupilating a tree in a non tree representstion.
The second solution is better since its a tree there are a lot of algorithms but there is more work on mapping back and forth on each addition or deletion.
What do you think is better? (A compromise between being it easier fof me and performance)
In the unforgettable words of Donald Knuth

Premature optimization is the root of all evil.

Your best option is as follows.  Do what is simplest for you, while maintaining a good abstraction with good encapsulation.  A good abstraction (a well-defined and thought out API) will make it easy for you to change and improve the underlying implementation in the future while not having to change the rest of the application.
When (or really if) you discover that the application is too slow, then you start changing the underlying implementation, but only after a proper complexity analysis.
It is very difficult (if not impossible) to say in advance what will be the bottleneck of the application, so it's best to leave this decision until you actually know.