Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 Problem statement You are a tired, erworked tearher who haa spent the last week orgix ing a field trip bor your entire middle school.
1 Problem statement You are a tired, erworked tearher who haa spent the last week orgix ing a field trip bor your entire middle school. The night before the trip, you realize you logot to plas the t impoctant part-traspotatioa! Fotu mately, your school hasaces to a large Heet o lw Being the caring teacher you'd like to enae that studs can still end p th samw Iis as their friends. Aer some investigative work on social ,you' man- aged to figure out exactly who is friends with who at your school and begin to assign studeuts to busas with the inteof becaking up asfew fricadships as posilse. o'wy just bgun when you recive a frantic mnil from cn ol the chaperones for the trip. The kids this year are partienlarh rowly, and the chaperones have given you a list of grps of students who get too rowdy when they are all toget f any o these groups are seated assigned to the a plan transortation while kreping both the students and the chaperones happ Formally, you're given an undiroeted graph V. an teger k, and an integer, we each ne in the raph desttand each ge (mMg) drnotew that Pendmt8and ''z are friemd8 The integrr k denotes the Dumber of buses anuilable and the integer s denotes the mumber of students that can fit on a singke bs. Furthermore, you're given a list L, where each eleme Ly is some subect od V whch cosponds to a group that should be lept apart Yoea partitice al G aset al sets of isViauc that In other words, every bus must be non empty, and must not bave more students on it than its capacity allows. Causilm a vertex u to IH, tulid if there is 0 and j such that Ly and tv V, 1n othrr wom18, 8 .rter is valid if it ix mt " remrly. 5Tertip whoee members all end up on the same bas. For exampk, f one of the rowdy groups was Alce. ob. and Carol thenptting Allce Bob'. Carol, and Dan' on tus worald lead to Alic,Bob' aCarol wing coled mal vertices Hewever, a b writh jst Alice, 'Ro, snd Dan wonld have po invulid vertices We'd ke you to produce a partitiou that maximas the perceut of odgss that occur betwoen vald vertices in the same partition in the graph. The seare or your pastition is the peeutgeos(u,) where u ande ae valid and u, u Vi finnerne i. Ye'd likv to prodora valid Tuartition with a8 hnh 2 Input format Each input consists of two Eles inside of a folder, graph-gal and parame ters.txt. The first file will contain your graph G in the GAIL. file format. Note that the mams o the verticss in you gaph MUST be uniqux alplhanumerie be found here. We highly recommend stients do not attempt to write their own methods for coaerting their grnps to gml fiks. We ustead encourage you to use existing liLeanes to du this -nutally, NetwutkX. Fix mue ialurauatan Theond file is n text file and will start with two integers esch on their own lin, the first being k, the mumber of buses and the secund being s. the tulilit al stulits that lit an each Itis. E uy sulsequeul ine will cultain a m-empty ist oferties which emps a single "owly that shmld mot all belong to the same bae For a single inpat, the name of the folder that contains the above two files denotes the identifier of that input Sample input parameters (Second File): Malfoy' 'Crabbe,'Goyle' 3 Output format For each input folder, you will gencrate a single output file with the name input-identifer>,out (eg. if the folder wis lained "coEympat" then the output shoal be named casy-iput.ut Ou each line of this ik there will bea nati Ellyty list cumtining aue af the *ubseta ia your partition of the graph. Every node in the graph shoni appar exartly once in this file. The numher of lines in this file should be exacty oqual to the mumber of buses specitied in the uput file and no lie should have ckments thanthe bus capacity specified ntbe input file Sample outputi CBary' Eerniono','Gorge'] Crsbbe,Goyle' 1 Problem statement You are a tired, erworked tearher who haa spent the last week orgix ing a field trip bor your entire middle school. The night before the trip, you realize you logot to plas the t impoctant part-traspotatioa! Fotu mately, your school hasaces to a large Heet o lw Being the caring teacher you'd like to enae that studs can still end p th samw Iis as their friends. Aer some investigative work on social ,you' man- aged to figure out exactly who is friends with who at your school and begin to assign studeuts to busas with the inteof becaking up asfew fricadships as posilse. o'wy just bgun when you recive a frantic mnil from cn ol the chaperones for the trip. The kids this year are partienlarh rowly, and the chaperones have given you a list of grps of students who get too rowdy when they are all toget f any o these groups are seated assigned to the a plan transortation while kreping both the students and the chaperones happ Formally, you're given an undiroeted graph V. an teger k, and an integer, we each ne in the raph desttand each ge (mMg) drnotew that Pendmt8and ''z are friemd8 The integrr k denotes the Dumber of buses anuilable and the integer s denotes the mumber of students that can fit on a singke bs. Furthermore, you're given a list L, where each eleme Ly is some subect od V whch cosponds to a group that should be lept apart Yoea partitice al G aset al sets of isViauc that In other words, every bus must be non empty, and must not bave more students on it than its capacity allows. Causilm a vertex u to IH, tulid if there is 0 and j such that Ly and tv V, 1n othrr wom18, 8 .rter is valid if it ix mt " remrly. 5Tertip whoee members all end up on the same bas. For exampk, f one of the rowdy groups was Alce. ob. and Carol thenptting Allce Bob'. Carol, and Dan' on tus worald lead to Alic,Bob' aCarol wing coled mal vertices Hewever, a b writh jst Alice, 'Ro, snd Dan wonld have po invulid vertices We'd ke you to produce a partitiou that maximas the perceut of odgss that occur betwoen vald vertices in the same partition in the graph. The seare or your pastition is the peeutgeos(u,) where u ande ae valid and u, u Vi finnerne i. Ye'd likv to prodora valid Tuartition with a8 hnh 2 Input format Each input consists of two Eles inside of a folder, graph-gal and parame ters.txt. The first file will contain your graph G in the GAIL. file format. Note that the mams o the verticss in you gaph MUST be uniqux alplhanumerie be found here. We highly recommend stients do not attempt to write their own methods for coaerting their grnps to gml fiks. We ustead encourage you to use existing liLeanes to du this -nutally, NetwutkX. Fix mue ialurauatan Theond file is n text file and will start with two integers esch on their own lin, the first being k, the mumber of buses and the secund being s. the tulilit al stulits that lit an each Itis. E uy sulsequeul ine will cultain a m-empty ist oferties which emps a single "owly that shmld mot all belong to the same bae For a single inpat, the name of the folder that contains the above two files denotes the identifier of that input Sample input parameters (Second File): Malfoy' 'Crabbe,'Goyle' 3 Output format For each input folder, you will gencrate a single output file with the name input-identifer>,out (eg. if the folder wis lained "coEympat" then the output shoal be named casy-iput.ut Ou each line of this ik there will bea nati Ellyty list cumtining aue af the *ubseta ia your partition of the graph. Every node in the graph shoni appar exartly once in this file. The numher of lines in this file should be exacty oqual to the mumber of buses specitied in the uput file and no lie should have ckments thanthe bus capacity specified ntbe input file Sample outputi CBary' Eerniono','Gorge'] Crsbbe,Goyle
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started