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 788281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:20:16+00:00 2026-05-14T21:20:16+00:00

I am operating on a (not so) large graph having about 380K edges. I

  • 0

I am operating on a (not so) large graph having about 380K edges. I wrote a program to count the number of 3-cliques in the graph. A quick example:

List of edges:
A - B
B - C
C - A
C - D

List of cliques:
A - B - C

MySQL Table structure:

+-------+------------+------+-----+---------+-------+
| Field | Type       | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| v1    | bigint(20) | YES  | MUL | NULL    |       | 
| v2    | bigint(20) | YES  | MUL | NULL    |       | 
+-------+------------+------+-----+---------+-------+

A 3-clique is nothing but a triangle in a graph. Currently, I am doing this using PHP+MySQL. As expected, it is not fast enough. Is there a way to do this in pure MySQL? (perhaps a way to insert all 3-cliques into a table?)

  • 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-05-14T21:20:17+00:00Added an answer on May 14, 2026 at 9:20 pm
    SELECT T1.v1, T2.v1, T3.v1 FROM TableName T1, TableName T2, TableName T3
    WHERE T1.v1 < T1.v2 AND T2.v1 < T2.v2 AND T3.v1 < T3.v2
    AND T1.v1 = T3.v1 AND T1.v2 = T2.v1 AND T2.v2 = T3.v2
    

    Should do the trick. What I’ve done there is ensure that v1 is less than v2 for all edges considered, simply to remove duplicates. Then it is a simple matter of joining up the edges by their start/end points. Returning the first point in each of the pairs.

    If you have edges going from a node back to the same node you may need to add in extra checks as appropriate.

    EDIT: Made a change, thanks to Legend.Reminded me that we needed to make sure that the edge found in T3 matches up to the edge in T1, so we have to link the first in each together! Originally I had T3.v1 > T3.v2 in the first line of the where clause but changed it to reduce confusion, forgot to change the second part though!

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

Sidebar

Related Questions

As I know Samsung Bada is not operating system but, just wonder if I
Is there any Operating System that do not support threading? I read somewhere CLI
Python's access to environment variables does not accurately reflect the operating system's view of
What operating system and UI toolkit is this? It's not some fake Hollywood user
I have a collection of items called RegisteredItems. I do not care about the
I am running on windows vista 64 bit operating system. Geografikos is a large
I have a few questions about storing files on the operating system. These may
I was reading about refactoring a large slow SQL Query over here , and
I'm working on a regression-testing tool that will validate a very large number of
Possible Duplicate: Cross-thread operation not valid I am trying to close the base of

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.