in reply to How to enable virtual paths inside a graph DS?

This would be easier if you were to use the inode-like implementation suggested on the previous question. Otherwise, use the rename_vertex method.

By the way, if you are also asking similar questions on StackOverflow, it is at the least good manners to cross-link between the two so people whom you're asking to expend effort know if the problem has already been solved.

Replies are listed 'Best First'.
Re^2: How to enable virtual paths inside a graph DS?
by ovedpo15 (Pilgrim) on Apr 26, 2022 at 10:41 UTC
    Uh sorry, I thought my solution is actually similar to how inode works. If not, can you please explain technically how the structure is structured? What each node keeps? And how to solve my current problem with it?
    Also, how rename_vertex can help with the current structure? Of course I need to rename the vertices, but figuring the algorithm is the problem.

      I think you've stated what the problem is using Graph as the representation. In a filesystem a symlink entry is a pointer to the complete destination name, whereas when you're storing things as nodes you're seeing each step in the destination as a separate node (and you've lost the notation that "/p" maps to "/a/b/c/d" (or whatever)).

      Little fuzzy, but I think you've gone a bit far afield trying to reimplement a filesystem. To do what you want (stipulated that I'm incautiously reading the problem) it almost seems to me that you want to have a list of links ordered from longest substitution to shortest and then walk that list of substitutions s{$cur_subst}{$cur_replacement} in that order.</handwavy>

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

        But I still do have the information that "/p" is a link to "/a/b/c/d" in my suggested graph. You have a node "/" which points to node "/p" which points to "/a/b/c/d". There is also another chain - node "/" points to "/a" which points to "/a/b" which points to "/a/b/c" which points to "/a/b/c/d".
        it almost seems to me that you want to have a list of links ordered from longest substitution to shortest
        Not sure why you think that but it might be because I didn't explain the question well enough. Given such graph, I want to replace any "logical path" with "virtual path". In other words, given some link with it's target, just go over the structure and replace the target with the link.
        Now, it might (probaby) be that my structure is not good enough for this task. @etj suggested to use inodes without getting into the real implementation of the inodes (since it's an overkill). But the current structure seems to be similar to what he was talking about. So if the better solution here is to rethink the structure - then how should it look like? How the nodes should be structured?