-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Edge has no __toString() #23
Comments
Depends on:
|
I expected a list of vertex IDs and a type. When developing with Graph it is handy not to single step but just print an item. I could have done echo $edge->getGraph(); but that would be information overload. IMHO every class should have a simple __toString() to give some info when needed. |
What about edge attributes such as flow, capacity, possibly even graphviz attributes? Perhaps people will even sub-class the Edge class? Imo, once we start adding a I can see were you're coming from, but I'm not quite sure how we should address these concerns? |
After some more consideration, how about this: class Edge
{
// [...]
public function __toString()
{
return $this->getGraph()->getExporter()->exportEdge($this);
}
} This way, the The default output could perhaps look something like this:
|
Proposed solution sound great indeed. The exporter decides what to dump. 👍 |
I've tinkered around with the idea of extending our Simply put, I'm not quite happy with this concept, so perhaps we should reconsider if adding a An alternative, and more explicit, approach would perhaps be something along the lines of: $exporter = new HumanReadableEdgeExporter();
echo $exporter->exportEdge($e1);
echo $exporter->exportEdge($e2); |
Ain't this fixed already? |
Depends on what your answer to my above question is :)
|
doh ... rereading I completely missed your point :/ ... Do we really need edge exporters or is that just an exporter ignoring graph and vertices? If the latter we can configure the exporter only to 'print' graph, edge or vertices depending on the current needs. I'm indifferent with the outcome as long as |
IMHO, yes. See the linked article for some arguments on how it breaks the SOLID principle. Also, once #26 lands and people are encouraged to extend the base classes, we won't be able to handle exporting their parameters either. Even currently, it's highly ambiguous what exactly to "export" (see my second comment). I can certainly see a desire to "export an edge", but I'm not convinced on that we can actually provide a satisfying result in the first place. Providing some base edge exporters would be a good start for others to build upon, IMHO. |
I still think it's a bad idea to implement We're working towards splitting off individual components via #120. As such, I don't think this repo should provide a default exporter for either of our entities. That being said, I still consider external |
Trying to
a single edge is not an option right now.
Should we add this?
The text was updated successfully, but these errors were encountered: