You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "safi50 (via GitHub)" <gi...@apache.org> on 2023/05/19 17:41:59 UTC

[GitHub] [age] safi50 opened a new issue, #935: Setting custom number of edges in create_complete_graph()

safi50 opened a new issue, #935:
URL: https://github.com/apache/age/issues/935

   I was trying to load sample data to my graph for some testing purposes. While creating  a sample 100 vertices using the following command: 
   ```
   SELECT * FROM create_complete_graph('test', 100, 'e', 'v');
   ```
   It creates a 100 sample vertices as expected:
   ```
   testdb=# select * from cypher('test', $$ match (n) return count(n)  $$) as ( a agtype);
     a  
   -----
    100
   (1 row)
   ```
   Whereas, it creates **9900** edges for those 100 sample vertices. 
   ```
   testdb=# select * from cypher('test', $$ match ()-[r]-()  return count (r)  $$) as ( a agtype);
     a   
   ------
    9900
   (1 row)
   ```
   I found that this is because each vertex has an edge connection to every other node in the graph making the total edges 
   as `(n-1) * n` where n is the total number of vertices in the graph. 
   
   What I am trying to figure out is, is there any way to create a custom number of edges as we do for the vertices.  For example, if i'm creating a 100 nodes , i would also like to set a custom number of edges i want in the graph. The edge connections, however, can be random. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] jrgemignani commented on issue #935: Setting custom number of edges in create_complete_graph()

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #935:
URL: https://github.com/apache/age/issues/935#issuecomment-1569344199

   @safi50 Please note that the query `match ()-[r]-()  return count (r)` is directionless. This means that it will match an edge going 1 direction, twice, because it does not care about direction.
   
   ```
   psql-11.5-5432-pgsql=# select from create_graph('test');
   NOTICE:  graph "test" has been created
   --
   (1 row)
   
   psql-11.5-5432-pgsql=# SELECT * FROM cypher('test', $$ create ()-[:knows]->() $$) as (r agtype);                                     r
   ---
   (0 rows)
   
   psql-11.5-5432-pgsql=# SELECT * FROM cypher('test', $$ match p=()-[:knows]-() return count(p) $$) as (r agtype);
    r
   ---
    2
   (1 row)
   
   psql-11.5-5432-pgsql=# SELECT * FROM cypher('test', $$ match p=()-[:knows]->() return count(p) $$) as (r agtype);
    r
   ---
    1
   (1 row)
   
   psql-11.5-5432-pgsql=#
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] safi50 closed issue #935: Setting custom number of edges in create_complete_graph()

Posted by "safi50 (via GitHub)" <gi...@apache.org>.
safi50 closed issue #935: Setting custom number of edges in create_complete_graph()
URL: https://github.com/apache/age/issues/935


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] safi50 commented on issue #935: Setting custom number of edges in create_complete_graph()

Posted by "safi50 (via GitHub)" <gi...@apache.org>.
safi50 commented on issue #935:
URL: https://github.com/apache/age/issues/935#issuecomment-1555880402

   > However, there are other graph generation algorithms that allow you to specify the number of edges.
   Thank you for your response @WendelLana. However, can you please specify some examples of above ?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] WendelLana commented on issue #935: Setting custom number of edges in create_complete_graph()

Posted by "WendelLana (via GitHub)" <gi...@apache.org>.
WendelLana commented on issue #935:
URL: https://github.com/apache/age/issues/935#issuecomment-1555046000

   A complete graph has edges connecting all pairs of distinct nodes. Therefore, in this function, you cannot set the number of edges. However, there are other graph generation algorithms that allow you to specify the number of edges. One example is the Watts-Strogatz Graph, which includes the argument 'k' where each node is joined with its 'k' nearest neighbors in a ring topology.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] AbdulSamad4068 commented on issue #935: Setting custom number of edges in create_complete_graph()

Posted by "AbdulSamad4068 (via GitHub)" <gi...@apache.org>.
AbdulSamad4068 commented on issue #935:
URL: https://github.com/apache/age/issues/935#issuecomment-1555063879

   the `create_complete_graph()` function you are using seems to generate the complete graph by default, connecting each vertex to every other vertex. If you want a different number of edges, you would need to modify the function or use a different approach.
   There are various algorithms and libraries available for generating random graphs, such as the Erdos-Renyi model, this model allows you to specify the number of vertices and edges to create a graph with a custom number of edges.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] hammadsaleemm commented on issue #935: Setting custom number of edges in create_complete_graph()

Posted by "hammadsaleemm (via GitHub)" <gi...@apache.org>.
hammadsaleemm commented on issue #935:
URL: https://github.com/apache/age/issues/935#issuecomment-1555870520

   Here's an example of how you can modify the query to create a graph with a custom number of edges:
   
   
   `SELECT * FROM create_custom_graph('test', 100, 500, 'e', 'v');`
   
   In this example, the create_custom_graph function takes four parameters:
   
   The graph name ('test' in this case).
   The number of vertices (100 in this case).
   The number of edges you want to create (500 in this case).
   The prefix for the edge and vertex IDs ('e' and 'v' respectively in this case).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] Munmud commented on issue #935: Setting custom number of edges in create_complete_graph()

Posted by "Munmud (via GitHub)" <gi...@apache.org>.
Munmud commented on issue #935:
URL: https://github.com/apache/age/issues/935#issuecomment-1563825398

   create_complete_graph() do this as follow
   ## What Completes Graph do
   A complete graph is a type of graph in graph theory where every pair of distinct vertices is connected by a unique edge. In other words, in a complete graph, each vertex is directly connected to every other vertex in the graph.
   
   A complete graph with n vertices is denoted as Kn, where "K" stands for complete and "n" represents the number of vertices. The total number of edges in a complete graph with n vertices can be calculated using the formula:
   
   E = n(n-1)/2
   
   In a complete graph, there are no isolated vertices since each vertex is connected to all other vertices. The degree of each vertex in a complete graph is (n-1) since each vertex is connected to all other (n-1) vertices.
   
   Complete graphs have several interesting properties and applications in graph theory and related fields. They are used as a benchmark for studying and comparing properties and algorithms in graph theory. Complete graphs also find applications in network topology, communication networks, and social network analysis, among others.
   
   ## How I Generate specific number of edges using python
   I used to work with the Age python driver and I use the following way to generate edges
   ```py
   import random
   number_of_nodes = 4000
   number_of_edges = 8000
   
   for i in range(number_of_nodes):
       # add node here using i as id property
       pass
   
   for i in range(number_of_edges):
       a = 0
       b = 0
       while(a==b):
           a = random.randint(0, number_of_nodes-1)
           b = random.randint(0, number_of_nodes-1)
       # add edge here using a and b to find specific node id
       pass
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] WendelLana commented on issue #935: Setting custom number of edges in create_complete_graph()

Posted by "WendelLana (via GitHub)" <gi...@apache.org>.
WendelLana commented on issue #935:
URL: https://github.com/apache/age/issues/935#issuecomment-1555904520

   I have been working on coding the Watts-Strogatz graph, which allows for the creation of edges with its 'k' nearest neighbors as the third argument. However, a function that generates a specified number of random edges does not currently exist


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org