Giter Site home page Giter Site logo

Comments (5)

jermainewang avatar jermainewang commented on September 18, 2024

from dgl.

mufeili avatar mufeili commented on September 18, 2024

Well, my point is that if we do g.edges[0, 1], users may wonder whether we are accessing the edge with src 0 and dest 1 or accessing two edges with edge ids 0 and 1.

from dgl.

jermainewang avatar jermainewang commented on September 18, 2024

I think this is our job of educating users. We should tell user that g.edges returns a view (same as networkx). The view object contains two convenient overloads:

  • __getitem__ to access data of the given edge(s).
  • __call__ to access all the edge ids.

g.edges[0, 1] is equivalent to g.edges.__getitem__((0, 1)) (in accordance with python). As a result, g.edges[0, 1] accesses one edge (0, 1).

list type is introduced in DGL to express multiple nodes/edges at once, which usually raises TypeError in normal container overload. Hence, accessing two edges at once should be g.edges[[0, 1]].

The rules are:

  • tuple type is reserved to represent edge with two endpoints. (for example, we should not allow g.edges[0, 1, 2]. That will be really confusing.).
  • list and tensor types are used to represent multiple node/edge ids.

from dgl.

jermainewang avatar jermainewang commented on September 18, 2024

Also, since __call__ is defined for g.edges. g.edges() will return the edge ids (in uv or eid). This also comes from the practice of networkx.

from dgl.

mufeili avatar mufeili commented on September 18, 2024

Alright, I will mention it in the doc.

from dgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.