Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8921361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:31:28+00:00 2026-06-15T06:31:28+00:00

I have a table which stores the edges of a directed graph like so:

  • 0

I have a table which stores the edges of a directed graph like so:

Table EDGES
  FROM_NODE | TO_NODE | STRENGTH
  1         | 1       | 8
  1         | 2       | 5
  2         | 1       | 4
  1         | 3       | 2
  3         | 4       | 1

And I’m trying to search for edges which are supported in both directions with strength > 3. In the example above, 1 -> 2 and 2 -> 1 both exist, however, 1 <-> 3 does not exist in both directions. 1 -> 1 doesn’t count, for obvious reasons.

The major complication is that there are over 1,000,000 edges to search, and all the queries I have tried so far fail before I can check if they’ve worked.

Any suggestions would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:31:30+00:00Added an answer on June 15, 2026 at 6:31 am

    To me the most straightforward solution is something like:

    select one.from_node, one.to_node 
    from edges one 
    join edges other on (one.to_node = other.from_node AND one.from_node = other.to_node)
    where one.strength > 3 AND other.strength > 3
        AND one.from_node <> one.to_node
    

    If you have a lot of data, than it’s might be a good idea to reconsider indexes on the table and raise the execution limit.

    Here is an sql fiddle to check the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which stores test results like this: user | score |
I have a table which stores a SQL predefined function, like CONVERT(VARCHAR(10), '2012-08-21 00:16:41.993',
I have a table which stores info about some events. I would like to
I have a table which stores both unix time and the equivalent time stamp.
I have a table which stores the data related to posts in this format
Imagine I have a table which stores a series of sparse vectors. A sparse
(I am using PostgreSQL) I have a table which stores transactions to an account.
While working with ActiveRecord I have a table which stores a serialized array of
I have a MYSQL-Table which stores scores. Every time a user improves a new
So I have a reference table which stores the primary key, description and update

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.