CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » June 2010 Contest » Graph Counting

Graph Counting

Problem code: GRAPHCT

  • All Submissions

All submissions for this problem are available.

First for some definitions :

Let G = (V,E) be an undirected graph containing an edge e = (u,v) with u ? v. Let f be a function which maps every vertex in V\{u,v} to itself, and otherwise, maps it to a new vertex w. The contraction of e results in a new graph G? = (V?,E?), where V? = (V\{u,v})?{w}, E? = E\{e}, and for every x ? V, x? = f(x) ? V? is incident to an edge e? ? E? if and only if, the corresponding edge, e ? E is incident to x in G.

An undirected graph H is called a minor of the graph G if H is isomorphic to a graph that can be obtained by zero or more edge contractions on a subgraph of G.

A graph is connected if there exists a path between any two vertices. A biconnected graph is one which remains connected even after the removal of any one vertex and all edges incident to it.

A simple graph is one which does not have more than one edge between any pair of vertex, nor does it have an edge from a vertex to itself.

You need to count how many simple biconnected graphs having n vertices and m edges exist such that they do not have a cycle of length 5 as a minor. Two graphs are considered distinct if there exist vertices having labels i and j which are adjacent in the first graph, but not in the second graph.

Input :

The first line contains the number of test cases T. Each of the next lines contains two integers n and m.

Output :

Output T lines, one corresponding to each test case. For a test case, output the number of graphs as described in the question. Output the answer modulo 1000000007.

Sample Input :
5
1 0
3 2
3 3
4 4
5 10

Sample Output :
1
0
1
3
0

Constraints :
1 <= T <= 2000
1 <= n <= 100
0 <= m <= 10000


Author: syco
Date Added: 9-04-2010
Time Limit: 2 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

n = 4, m = 4 => only one

hypothesis testing @ 1 Jun 2010 04:30 PM

n = 4, m = 4 => only one biconnected graph is possible so how come the answer is 3 for this case?

just to be clear - two graphs are considered to be distinct if they are non isomorphic ?

Read the last sentence before

triplem @ 1 Jun 2010 04:34 PM

Read the last sentence before 'Input'.

what is the meaning of this

hardcode @ 2 Jun 2010 04:35 PM

what is the meaning of this notation :'V{u,v} ' or  'E{e}' ?

The edge contraction

Tool @ 2 Jun 2010 10:08 PM

The edge contraction description is a little hard to understand. Is it just deleting the edge between two vertices and merging the vertices together into one vertex that has both the vertices' adjacencies? That would sound like the standard definition

Edge contraction definition

sppraveen @ 3 Jun 2010 02:19 PM

Edge contraction definition is not clear to me. I can understand Tedrick said. Is that what is meant the normal edge contraction?

Can any1 explain in short wat

AnoopNarang @ 4 Jun 2010 03:03 AM

Can any1 explain in short wat we have to do??. ... i dont know a s*** abt this f***in graph theory ... :(

All definitions in the

triplem @ 4 Jun 2010 06:48 AM

All definitions in the problem statement are standard definitions. Though they are clearly defined, if you don't understand them you could try Wikipedia for more details on what the words mean. Biconnected, simple graph, minor, cycle, isomorphic all have pages on Wikipedia for you to read.

  "they do not have a cycle

liubiaoyong @ 5 Jun 2010 04:48 AM

 

"they do not have a cycle of length 5 as a minor"

means :

the graph can have a cycle, but the length of the cycle must be <= 5 .

right ?

It means exactly what it says

triplem @ 5 Jun 2010 04:53 AM

It means exactly what it says according to the definition of a minor. Any further implications on what this means in the graph is part of solving the problem, do not discuss that.

Does cycle mean cycle with

ankit1990 @ 7 Jun 2010 02:01 PM

Does cycle mean cycle with repeated vertices or not ? Admin please clarify .

There is only one definition

triplem @ 7 Jun 2010 02:30 PM

There is only one definition of a cycle. http://en.wikipedia.org/wiki/Cycle_graph

Thanks stephen, actually I

ankit1990 @ 7 Jun 2010 02:41 PM

Thanks stephen, actually I was referring to http://en.wikipedia.org/wiki/Cycle_(graph_theory) . Hence the confusion .

what is the meaning of this

codegambler @ 9 Jun 2010 09:59 AM

what is the meaning of this line "they do not have a cycle of length 5 as a minor" can anyone explain the given test case

4 4

how it is 3?

All of those words are

triplem @ 9 Jun 2010 10:07 AM

All of those words are clearly defined in the problem statement - what part don't you understand?

@stephen can you please

codegambler @ 9 Jun 2010 10:12 AM

@stephen can you please explain the result for 4 4, I need one example to undestand. I read all the definitions. but i didn't understand the test case 4 4. :( what are the 3 graphs?

The graphs with vertices 1,

triplem @ 9 Jun 2010 10:20 AM

The graphs with vertices 1, 2, 3, 4 have these edges:

a) 1-2, 1-4, 2-3, 3-4

b) 1-2, 1-3, 2-4, 3-4

c) 1-3, 1-4, 2-3, 2-4

if i named 2 by 3 and 3 by 2.

codegambler @ 9 Jun 2010 10:45 AM

if i named 2 by 3 and 3 by 2. for (c) the it is identical to (a).

So what? The problem

triplem @ 9 Jun 2010 11:04 AM

So what? The problem statement says:

Two graphs are considered distinct if there exist vertices having labels i and j which are adjacent in the first graph, but not in the second graph.

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com