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

I am not clear about thread confinement. In swing all the gui components must
Our application stores user files on the physical drives (alebit a large number of
I am using windbg with xp embedded. Attempting to fetch the operating system symbols
I am seeing a problem where I send large messages over wcf net.msmq using
I've been using OpenProcess with PROCESS_ALL_ACCESS rights for the following functions: -EnumProcessModules -GetModuleFileNameEx -ReadProcessMemory
I have a page (page 1), dated February 2, 1989 that my former boss
I have a WPF application rendering fonts to a larger size than I expect.
I have a web application in Spring that has a functional requirement for generating
We've been using the sys.database_files view and the FILEPROPERTY function to get the size
I have a char[26] of the letters a-z and via nested for statements I'm

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.