Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more encapsulations #12

Closed
suntong opened this issue Jul 8, 2016 · 4 comments
Closed

Add more encapsulations #12

suntong opened this issue Jul 8, 2016 · 4 comments

Comments

@suntong
Copy link

suntong commented Jul 8, 2016

I need to access the Edges internal data:

type Edges struct {
    SrcToDsts map[string]map[string]*Edge
    DstToSrcs map[string]map[string]*Edge
    Edges     []*Edge
}

but I don't want to dip directly into the above data structure, but would like to access them through encapsulations instead. So, I'd like to propose the following access methods:

// EdgesToParents returns all the edges linked to its parents of the given nodeName.
EdgesToParents(nodeName string) map[string]... => return DstToSrcs[nodeName]

// EdgesToChildren returns all the edges linked to its children of the given nodeName.
EdgesToChildren(nodeName string) map[string]... => return SrcToDsts[nodeName]

Or something similar. Would that be OK? I don't mind patch myself and send in the pull request.

Moreover, I also need the access method of NodesAll for all the nodes within the given Graph:

// NodesAll returns all the nodes within the given Graph.

Would that be OK to have such encapsulations? Again, I don't mind patch myself and send in the pull request.

Thanks

@awalterschulze
Copy link
Owner

I think you could easily build those methods on a structure which embeds the Graph structure, or am I missing something?
Also EdgesToParent and Children gives the wrong idea, in my opinion, since Parents and Children typically refer the Subgraphs.
How about GetEdgesToDestination and GetEdgesFromSource?

NodesAll, how about GetNodes?
The Nodes field contains all the Nodes.

Where are do you want to use these methods?

@suntong
Copy link
Author

suntong commented Jul 8, 2016

I think you could easily build those methods on a structure which embeds the Graph structure, or am I missing something?

I tried that before, yes, I can build those methods, but I also bumped into problems like the following.

invalid operation: attrs[name] (index of type Attrs)
cannot use sub.Attrs (type gographviz.Attrs) as type Attrs in function argument
cannot use this.ClusterGraph.Graph.Graph.Attrs (type gographviz.Attrs) as type Attrs in function argument
cannot use edge (type *gographviz.Edge) as type *Edge in function argument

I.e., I wasn't able to use my structure as a direct replacement of the Graph structure before. Maybe I did something wrong. Anyway, if you don't mind, I hope those encapsulation wrappings are in gographviz instead of mine.

So would one pull request containing two separated commits of adding GetEdgesToDestination & GetEdgesFromSource, and adding GetNodes be OK with you?

Where are do you want to use these methods?

I'm more interested in traversing the graph than presenting them. So knowing the nodes, the edges is the very least I need. More encapsulation wrappings might be need. I'll consult with you in new threads after we finish this.

Thanks

@awalterschulze
Copy link
Owner

Maybe you could show me the code that gives you those errors?

@awalterschulze
Copy link
Owner

No reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants